当前位置: 首页>>代码示例>>Java>>正文


Java Cursor.getLong方法代码示例

本文整理汇总了Java中android.database.Cursor.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.getLong方法的具体用法?Java Cursor.getLong怎么用?Java Cursor.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.getLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContactInfo

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public ContactInfo getContactInfo(Context context, Cursor cursor) {
    ContactInfo ci = new ContactInfo();
    // Get values
    ci.displayName = cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME));
    ci.contactId = cursor.getLong(cursor.getColumnIndex(Contacts._ID));
    ci.callerInfo.contactContentUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, ci.contactId);
    ci.callerInfo.photoId = cursor.getLong(cursor.getColumnIndex(Contacts.PHOTO_ID));
    int photoUriColIndex = cursor.getColumnIndex(Contacts.PHOTO_ID);
    ci.status = cursor.getString(cursor.getColumnIndex(Contacts.CONTACT_STATUS));
    ci.presence = cursor.getInt(cursor.getColumnIndex(Contacts.CONTACT_PRESENCE));

    if (photoUriColIndex >= 0) {
        String photoUri = cursor.getString(photoUriColIndex);
        if (!TextUtils.isEmpty(photoUri)) {
            ci.callerInfo.photoUri = Uri.parse(photoUri);
        }
    }
    ci.hasPresence = !TextUtils.isEmpty(ci.status);
    return ci;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:22,代码来源:ContactsUtils5.java

示例2: getPlaylistSongFromCursorImpl

import android.database.Cursor; //导入方法依赖的package包/类
@NonNull
private static PlaylistSong getPlaylistSongFromCursorImpl(@NonNull Cursor cursor, int playlistId) {
    final int id = cursor.getInt(0);
    final String title = cursor.getString(1);
    final int trackNumber = cursor.getInt(2);
    final int year = cursor.getInt(3);
    final long duration = cursor.getLong(4);
    final String data = cursor.getString(5);
    final int dateModified = cursor.getInt(6);
    final int albumId = cursor.getInt(7);
    final String albumName = cursor.getString(8);
    final int artistId = cursor.getInt(9);
    final String artistName = cursor.getString(10);
    final int idInPlaylist = cursor.getInt(11);

    return new PlaylistSong(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName, playlistId, idInPlaylist);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:18,代码来源:PlaylistSongsLoader.java

示例3: getThreadIdIfExistsFor

import android.database.Cursor; //导入方法依赖的package包/类
public long getThreadIdIfExistsFor(Recipients recipients) {
  long[] recipientIds    = getRecipientIds(recipients);
  String recipientsList  = getRecipientsAsString(recipientIds);
  SQLiteDatabase db      = databaseHelper.getReadableDatabase();
  String where           = RECIPIENT_IDS + " = ?";
  String[] recipientsArg = new String[] {recipientsList};
  Cursor cursor          = null;

  try {
    cursor = db.query(TABLE_NAME, new String[]{ID}, where, recipientsArg, null, null, null);

    if (cursor != null && cursor.moveToFirst())
      return cursor.getLong(cursor.getColumnIndexOrThrow(ID));
    else
      return -1L;
  } finally {
    if (cursor != null)
      cursor.close();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:21,代码来源:ThreadDatabase.java

示例4: getBookmarkId

import android.database.Cursor; //导入方法依赖的package包/类
public long getBookmarkId(Integer sura, Integer ayah, int page) {
  Cursor cursor = null;
  try {
    cursor = mDb.query(BookmarksTable.TABLE_NAME,
        null, BookmarksTable.PAGE + "=" + page + " AND " +
            BookmarksTable.SURA + (sura == null ? " IS NULL" : "=" + sura) +
            " AND " + BookmarksTable.AYAH +
            (ayah == null ? " IS NULL" : "=" + ayah), null, null, null, null);
    if (cursor != null && cursor.moveToFirst()) {
      return cursor.getLong(0);
    }
  } catch (Exception e) {
    // swallow the error for now
  } finally {
    DatabaseUtils.closeCursor(cursor);
  }
  return -1;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:19,代码来源:BookmarksDBAdapter.java

示例5: isAppropriateTypeForMigration

import android.database.Cursor; //导入方法依赖的package包/类
private static boolean isAppropriateTypeForMigration(Cursor cursor, int columnIndex) {
  long systemType = cursor.getLong(columnIndex);
  long ourType    = SmsDatabase.Types.translateFromSystemBaseType(systemType);

  return ourType == MmsSmsColumns.Types.BASE_INBOX_TYPE ||
         ourType == MmsSmsColumns.Types.BASE_SENT_TYPE ||
         ourType == MmsSmsColumns.Types.BASE_SENT_FAILED_TYPE;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:SmsMigrator.java

示例6: getLastSeen

import android.database.Cursor; //导入方法依赖的package包/类
public long getLastSeen(long threadId) {
  SQLiteDatabase db     = databaseHelper.getReadableDatabase();
  Cursor         cursor = db.query(TABLE_NAME, new String[]{LAST_SEEN}, ID_WHERE, new String[]{String.valueOf(threadId)}, null, null, null);

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

    return -1;
  } finally {
    if (cursor != null) cursor.close();
  }

}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:16,代码来源:ThreadDatabase.java

示例7: onActivityCreated

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    activity = (MainActivity) getActivity();

    //rooms(id, name, type)
    //room_types(id, type_name)
    Cursor c = activity.mDb.rawQuery("SELECT r.id, r.name, rt.type_name FROM rooms r INNER JOIN room_types rt ON r.type=rt.id", new String[]{});
    c.moveToFirst();
    int idIdx = c.getColumnIndex("id");
    int nameIdx = c.getColumnIndex("name");
    int typeIdx = c.getColumnIndex("type_name");
    rooms = new ArrayList<>();
    roomTypes = new ArrayList<>();
    roomNames = new ArrayList<>();

    while (c.moveToNext()) {
        long id = c.getLong(idIdx);
        String name = c.getString(nameIdx);
        roomNames.add(name);
        String type = c.getString(typeIdx);
        roomTypes.add(type);
        rooms.add(name + " (" + type + ")");
    }

    ListAdapter adapter = new ArrayAdapter<>(getActivity(),
            R.layout.rooms_layout_item_1, rooms.toArray());
    setListAdapter(adapter);
}
 
开发者ID:Harrix,项目名称:uchimznaem-helper,代码行数:30,代码来源:RoomsListFragment.java

示例8: insertMessageFromEntry

import android.database.Cursor; //导入方法依赖的package包/类
private static void insertMessageFromEntry(InboxManager inboxManager, Cursor entryCursor) {
    int id = entryCursor.getInt(entryCursor.getColumnIndex("_id"));
    int threadId = entryCursor.getInt(entryCursor.getColumnIndex(DBMigratorSQLiteHelper.INBOX_ENTRIES_COLUMN_THREAD_ID));
    String appId = entryCursor.getString(entryCursor.getColumnIndex("_app_id"));
    String senderId = entryCursor.getString(entryCursor.getColumnIndex("_sender_id"));
    String from = entryCursor.getString(entryCursor.getColumnIndex("_from"));
    String message = entryCursor.getString(entryCursor.getColumnIndex(DBMigratorSQLiteHelper.INBOX_ENTRIES_COLUMN_MESSAGE));
    long timestamp = entryCursor.getLong(entryCursor.getColumnIndex("_timestamp"));
    int state = entryCursor.getInt(entryCursor.getColumnIndex("_state"));
    String extra = entryCursor.getString(entryCursor.getColumnIndex("_extra"));
    RawMessage rawMessage = new RawMessage(appId, senderId, from, message, timestamp, null, null, null);
    rawMessage.setState(1);
    inboxManager.injectMessage(rawMessage);
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:15,代码来源:DBMigrator.java

示例9: includeAlbum

import android.database.Cursor; //导入方法依赖的package包/类
private void includeAlbum(MatrixCursor result, Cursor cursor) {
    final long id = cursor.getLong(AlbumQuery._ID);
    final String docId = getDocIdForIdent(TYPE_ALBUM, id);

    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME,
            cleanUpMediaDisplayName(cursor.getString(AlbumQuery.ALBUM)));
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
    row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID
            | Document.FLAG_SUPPORTS_THUMBNAIL | Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_SUPPORTS_DELETE);
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:13,代码来源:MediaDocumentsProvider.java

示例10: cursorToMemory

import android.database.Cursor; //导入方法依赖的package包/类
private Memory cursorToMemory(Cursor cursor){
    Memory memory = new Memory();
    memory.id = cursor.getLong(0);
    memory.city = cursor.getString(1);
    memory.country = cursor.getString(2);
    memory.latitude = cursor.getDouble(3);
    memory.longitude = cursor.getDouble(4);
    memory.notes = cursor.getString(5);
    return memory;
}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:11,代码来源:MemoriesDataSource.java

示例11: readEntity

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public User readEntity(Cursor cursor, int offset) {
    User entity = new User( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
        cursor.getInt(offset + 2) // age
    );
    return entity;
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:10,代码来源:UserDao.java

示例12: getAlbumForPathCleared

import android.database.Cursor; //导入方法依赖的package包/类
protected long getAlbumForPathCleared(String path) throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI,
        		AudioAlbumThumbnailQuery.PROJECTION, Audio.Media.DATA + " LIKE ?",
        		new String[] { path.replaceAll("'", "''") }, Audio.Media.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(AudioAlbumThumbnailQuery.ALBUM_ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No Audio found for album");
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:16,代码来源:StorageProvider.java

示例13: readEntity

import android.database.Cursor; //导入方法依赖的package包/类
/** @inheritdoc */
@Override
public FollowerLink readEntity(Cursor cursor, int offset) {
    FollowerLink entity = new FollowerLink( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // type
        cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // BUserDaoId
        cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3) // linkOwnerBUserDaoId
    );
    return entity;
}
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:12,代码来源:FollowerLinkDao.java

示例14: update

import android.database.Cursor; //导入方法依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
    if (MATCHER.match(uri) != CODE_APK_FROM_REPO) {
        throw new UnsupportedOperationException("Cannot update anything other than a single apk.");
    }

    boolean saveAntiFeatures = false;
    String[] antiFeatures = null;
    if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) {
        saveAntiFeatures = true;
        String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES);
        antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString);
        values.remove(Cols.AntiFeatures.ANTI_FEATURES);
    }

    validateFields(Cols.ALL, values);
    removeFieldsFromOtherTables(values);

    QuerySelection query = new QuerySelection(where, whereArgs);
    query = query.add(querySingleWithAppId(uri));

    int numRows = db().update(getTableName(), values, query.getSelection(), query.getArgs());

    if (saveAntiFeatures) {
        // Get the database ID of the row we just updated, so that we can join relevant anti features to it.
        Cursor result = db().query(getTableName(), new String[]{Cols.ROW_ID},
                query.getSelection(), query.getArgs(), null, null, null);
        if (result != null) {
            result.moveToFirst();
            long apkId = result.getLong(0);
            ensureAntiFeatures(antiFeatures, apkId);
            result.close();
        }
    }

    if (!isApplyingBatch()) {
        getContext().getContentResolver().notifyChange(uri, null);
    }
    return numRows;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:41,代码来源:ApkProvider.java

示例15: 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:popo1379,项目名称:popomusic,代码行数:5,代码来源:MusicBeanDao.java


注:本文中的android.database.Cursor.getLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。