本文整理汇总了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);
}