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