ページの先頭行へ戻る
Interstage Mobile Application Server V1.2.0 アプリケーション開発ガイド
FUJITSU Software

4.6.3 データの削除、データ数およびキーの取得

SLSのAPIでは、格納されたデータの削除やキーを取得する事ができます。以下は認証レスモードの例です。


使用例
Android
     try {
         DataManagerModeLessDirect dm = new DataManagerModeLessDirect(getApplicationContext());
         int count = dm.getListLength();
         for (int i=count-1; i >= 0; i--){
              String key = dm.getKeyFromIndex(i);
              dm.remove(key);
          }
     } catch (IMAPSSlsException e) {
         // 例外処理.
     }
iOS
- (void)func
{
    NSError *anError = nil;
    IMADataManagerModeLessDirect *manager = [[IMADataManagerModeLessDirect alloc] init];
    NSNumber *count = [manager getListLength:&anError];
    if (count == nil) {
        // それぞれのエラーの実装.
    }

    int intCount = [count intValue];
    for(int i = intCount-1; i >= 0; i--) {
        NSString *key = [manager getKeyFromIndex:i error:&anError];
        if (key == nil) {
            // それぞれのエラーの実装.
        }
        BOOL ret = [manager remove:key error:&anError];
        if (ret == NO) {
            // それぞれのエラーの実装
        }
    }
}
Windows
    try
    {
        DataManagerModeLessDirect dm = new DataManagerModeLessDirect();
        int count = dm.getListLength(true);
        for (int i=count-1; i >= 0; i--)
        {
            string key = dm.getKeyFromIndex(i);
            dm.remove(key);
        }
    }
    catch (IMAPSSlsException e)
    {
        // 例外処理
    }