当前位置: 首页>>代码示例>>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;未经允许,请勿转载。