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

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

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


使用例:Android

     try {
         DataManagerModeLessDirect dm = new DataManagerModeLessDirect(getApplicationContext(),true);
         int count = dm.getListLength();
         for (int i=1; i < count; i++){
              String key = dm.getKeyFromIndex(i);
              dm.remove(key);
          }
     } catch (IMAPSSlsException e) {
         // 例外処理.
     }

使用例:iOS

- (void)func
{
    NSError *anError = nil;
    IMADataManagerModeLessDirect *manager = [[IMADataManagerModeLessDirect alloc] init:NO];
    NSNumber *count = [manager getListLength:&anError];
    if (count == nil) {
        // それぞれのエラーの実装.
    }

    int intCount = [count intValue];
    for(int i = 0; i < intCount; i++) {
        NSString *key = [manager getKeyFromIndex:i error:&anError];
        if (key == nil) {
            // それぞれのエラーの実装.
        }
        BOOL ret = [manager remove:key error:&anError];
        if (ret == NO) {
            // それぞれのエラーの実装
        }
    }
}