當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.isNull方法代碼示例

本文整理匯總了Java中android.database.Cursor.isNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.isNull方法的具體用法?Java Cursor.isNull怎麽用?Java Cursor.isNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.isNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryForString

import android.database.Cursor; //導入方法依賴的package包/類
private static String queryForString(Context context, Uri self, String column, String defaultValue) {
    Cursor c = null;
    try {
        c = context.getContentResolver().query(self, new String[]{column}, null, null, null);
        if (!c.moveToFirst() || c.isNull(0)) {
            closeQuietly(c);
            return defaultValue;
        }
        defaultValue = c.getString(0);
        return defaultValue;
    } catch (Exception e) {
        Log.w(TAG, "Failed query: " + e);
    } finally {
        closeQuietly(c);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:DocumentsContractApi19.java

示例2: queryForString

import android.database.Cursor; //導入方法依賴的package包/類
private static String queryForString(Context context, Uri self, String column,
        String defaultValue) {
    final ContentResolver resolver = context.getContentResolver();

    Cursor c = null;
    try {
        c = resolver.query(self, new String[] { column }, null, null, null);
        if (c.moveToFirst() && !c.isNull(0)) {
            return c.getString(0);
        } else {
            return defaultValue;
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed query: " + e);
        return defaultValue;
    } finally {
        closeQuietly(c);
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:20,代碼來源:DocumentsContractCompat.java

示例3: getSongCountForAlbumInt

import android.database.Cursor; //導入方法依賴的package包/類
/**
 * @param context The {@link Context} to use.
 * @param id      The id of the album.
 * @return The song count for an album.
 */
public static final int getSongCountForAlbumInt(final Context context, final long id) {
    int songCount = 0;
    if (id == -1) {
        return songCount;
    }

    Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, id);
    Cursor cursor = context.getContentResolver().query(uri,
            new String[]{AlbumColumns.NUMBER_OF_SONGS}, null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            if (!cursor.isNull(0)) {
                songCount = cursor.getInt(0);
            }
        }
        cursor.close();
        cursor = null;
    }

    return songCount;
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:28,代碼來源:MusicUtils.java

示例4: getAttachmentDataFile

import android.database.Cursor; //導入方法依賴的package包/類
private @Nullable File getAttachmentDataFile(@NonNull AttachmentId attachmentId,
                                             @NonNull String dataType)
{
  SQLiteDatabase database = databaseHelper.getReadableDatabase();
  Cursor         cursor   = null;

  try {
    cursor = database.query(TABLE_NAME, new String[]{dataType}, PART_ID_WHERE, attachmentId.toStrings(),
                            null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      if (cursor.isNull(0)) {
        return null;
      }

      return new File(cursor.getString(0));
    } else {
      return null;
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:26,代碼來源:AttachmentDatabase.java

示例5: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public KeepEntity readEntity(Cursor cursor, int offset) {
    KeepEntity entity = new KeepEntity( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0) // id
    );
    return entity;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:KeepEntityDao.java

示例6: addIntToStatement

import android.database.Cursor; //導入方法依賴的package包/類
private static void addIntToStatement(SQLiteStatement statement, Cursor cursor,
                                      int index, String key)
{
  int columnIndex = cursor.getColumnIndexOrThrow(key);

  if (cursor.isNull(columnIndex)) {
    statement.bindNull(index);
  } else {
    statement.bindLong(index, cursor.getLong(columnIndex));
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:12,代碼來源:SmsMigrator.java

示例7: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public LocalUser readEntity(Cursor cursor, int offset) {
    LocalUser entity = new LocalUser( //
        cursor.getString(offset + 0), // login
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // avatarUrl
        cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // followers
        cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4) // following
    );
    return entity;
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:12,代碼來源:LocalUserDao.java

示例8: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Trace readEntity(Cursor cursor, int offset) {
    Trace entity = new Trace( //
        cursor.getString(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // type
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // userId
        cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // repoId
        cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)), // startTime
        cursor.isNull(offset + 5) ? null : new java.util.Date(cursor.getLong(offset + 5)), // latestTime
        cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6) // traceNum
    );
    return entity;
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:14,代碼來源:TraceDao.java

示例9: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public SqliteMaster readEntity(Cursor cursor, int offset) {
    SqliteMaster entity = new SqliteMaster( //
        cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // type
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // tableName
        cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3), // rootpage
        cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // sql
    );
    return entity;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:SqliteMasterDao.java

示例10: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Statistic readEntity(Cursor cursor, int offset) {
    Statistic entity = new Statistic( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.getString(offset + 1), // name
        cursor.getDouble(offset + 2), // quantity
        cursor.getDouble(offset + 3), // totalCost
        cursor.getShort(offset + 4) != 0, // unit
        cursor.getLong(offset + 5) // date
    );
    return entity;
}
 
開發者ID:Lidchanin,項目名稱:Shopping_List,代碼行數:13,代碼來源:StatisticDao.java

示例11: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
/** @inheritdoc */
@Override
public BUser readEntity(Cursor cursor, int offset) {
    BUser entity = new BUser( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // entityID
        cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2), // AuthenticationType
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // messageColor
        cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)), // lastOnline
        cursor.isNull(offset + 5) ? null : new java.util.Date(cursor.getLong(offset + 5)), // lastUpdated
        cursor.isNull(offset + 6) ? null : cursor.getShort(offset + 6) != 0, // Online
        cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // Metadata
    );
    return entity;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:16,代碼來源:BUserDao.java

示例12: readEntity

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public ToManyTargetEntity readEntity(Cursor cursor, int offset) {
    ToManyTargetEntity entity = new ToManyTargetEntity( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // toManyId
        cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // toManyIdDesc
        cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // id
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // targetJoinProperty
    );
    return entity;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:ToManyTargetEntityDao.java

示例13: getSnippetUri

import android.database.Cursor; //導入方法依賴的package包/類
private @Nullable Uri getSnippetUri(Cursor cursor) {
  if (cursor.isNull(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_URI))) {
    return null;
  }

  try {
    return Uri.parse(cursor.getString(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_URI)));
  } catch (IllegalArgumentException e) {
    Log.w(TAG, e);
    return null;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:13,代碼來源:ThreadDatabase.java

示例14: readKey

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Long readKey(Cursor cursor, int offset) {
    return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:AnActiveEntityDao.java

示例15: readKey

import android.database.Cursor; //導入方法依賴的package包/類
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
    return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:6,代碼來源:FollowerLinkDao.java


注:本文中的android.database.Cursor.isNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。