本文整理匯總了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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}