本文整理汇总了Java中android.database.Cursor.moveToPrevious方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.moveToPrevious方法的具体用法?Java Cursor.moveToPrevious怎么用?Java Cursor.moveToPrevious使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.moveToPrevious方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllTasks
import android.database.Cursor; //导入方法依赖的package包/类
public List<TasksManagerModel> getAllTasks() {
final Cursor c = db.rawQuery("SELECT * FROM " + TABLE_NAME, null);
final List<TasksManagerModel> list = new ArrayList<>();
try {
if (!c.moveToLast()) {
return list;
}
do {
TasksManagerModel model = new TasksManagerModel();
model.setId(c.getInt(c.getColumnIndex(TasksManagerModel.ID)));
model.setName(c.getString(c.getColumnIndex(TasksManagerModel.NAME)));
model.setUrl(c.getString(c.getColumnIndex(TasksManagerModel.URL)));
model.setPath(c.getString(c.getColumnIndex(TasksManagerModel.PATH)));
list.add(model);
} while (c.moveToPrevious());
} finally {
if (c != null) {
c.close();
}
}
return list;
}
示例2: readContactDetails
import android.database.Cursor; //导入方法依赖的package包/类
private void readContactDetails(Cursor cursor) {
if (cursor != null && cursor.moveToFirst()) {
cursor.moveToPrevious();
while (cursor.moveToNext()) {
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.LOOKUP_KEY));
ContactImpl contact = mContactsByLookupKey.get(lookupKey);
if (contact != null) {
readContactDetails(cursor, contact);
}
}
}
sortAndPostCopy(mContacts);
joinContactsAndGroups(mContacts);
}
示例3: cancelMultipleDownloads
import android.database.Cursor; //导入方法依赖的package包/类
/**
* @param c cursor moved byond its last position
* @param columnIndex the index for enqueId in the Cursor
*/
public void cancelMultipleDownloads(Cursor c, int columnIndex) {
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
try {
while (c.moveToPrevious()) {
long enquId = c.getLong(columnIndex);
db.delete(BooksInformationDBContract.StoredBooks.TABLE_NAME,
BooksInformationDBContract.StoredBooks.COLUMN_NAME_ENQID + "=?",
new String[]{Long.toString(enquId)});
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
示例4: EmailProviderCacheCursor
import android.database.Cursor; //导入方法依赖的package包/类
public EmailProviderCacheCursor(String accountUuid, Cursor cursor, Context context) {
super(cursor);
mCache = EmailProviderCache.getCache(accountUuid, context);
mMessageIdColumn = cursor.getColumnIndex(MessageColumns.ID);
mFolderIdColumn = cursor.getColumnIndex(MessageColumns.FOLDER_ID);
mThreadRootColumn = cursor.getColumnIndex(ThreadColumns.ROOT);
if (mMessageIdColumn == -1 || mFolderIdColumn == -1 || mThreadRootColumn == -1) {
throw new IllegalArgumentException("The supplied cursor needs to contain the " +
"following columns: " + MessageColumns.ID + ", " + MessageColumns.FOLDER_ID +
", " + ThreadColumns.ROOT);
}
while (cursor.moveToNext()) {
long messageId = cursor.getLong(mMessageIdColumn);
long folderId = cursor.getLong(mFolderIdColumn);
if (mCache.isMessageHidden(messageId, folderId)) {
mHiddenRows.add(cursor.getPosition());
}
}
// Reset the cursor position
cursor.moveToFirst();
cursor.moveToPrevious();
}
示例5: readContacts
import android.database.Cursor; //导入方法依赖的package包/类
private void readContacts(Cursor cursor) {
mContacts.clear();
mContactsByLookupKey.clear();
mNrOfSelectedContacts = 0;
int count = 0;
if (cursor.moveToFirst()) {
cursor.moveToPrevious();
while (cursor.moveToNext()) {
ContactImpl contact = ContactImpl.fromCursor(cursor);
mContacts.add(contact);
// LOOKUP_KEY is the one we use to retrieve the contact when the contact details are loaded
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
mContactsByLookupKey.put(lookupKey, contact);
boolean isChecked = mSelectedContactIds.contains(contact.getId());
contact.setChecked(isChecked, true);
mNrOfSelectedContacts += isChecked ? 1 : 0;
contact.addOnContactCheckedListener(mContactListener);
// update the ui once some contacts have loaded
if (++count >= BATCH_SIZE) {
sortAndPostCopy(mContacts);
count = 0;
}
}
}
if (count > 0) {
sortAndPostCopy(mContacts);
}
updateTitle();
}
示例6: onClick
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
ContactInfo ci = (ContactInfo) view.getTag();
List<String> phones = ContactsWrapper.getInstance().getCSipPhonesContact(mContext, ci.contactId);
boolean useCSip = true;
String toCall = null;
if(phones != null && phones.size() > 0) {
toCall = phones.get(0);
}else {
List<Phone> cPhones = ContactsWrapper.getInstance().getPhoneNumbers(mContext, ci.contactId, ContactsWrapper.URI_ALLS);
if(cPhones != null && cPhones.size() > 0) {
toCall = cPhones.get(0).getNumber();
useCSip = false;
}
}
if(!TextUtils.isEmpty(toCall) ) {
Cursor c = (Cursor) getItem((Integer) ci.userData);
Long profileId = null;
while(c.moveToPrevious()) {
int cTypeIdx = c.getColumnIndex(ContactsWrapper.FIELD_TYPE);
int cAccIdx = c.getColumnIndex(BaseColumns._ID);
if(cTypeIdx >= 0 && cAccIdx >= 0) {
if(c.getInt(cTypeIdx) == ContactsWrapper.TYPE_GROUP) {
profileId = c.getLong(cAccIdx);
break;
}
}
}
Intent it = new Intent(Intent.ACTION_CALL);
it.setData(SipUri.forgeSipUri(useCSip ? SipManager.PROTOCOL_CSIP : SipManager.PROTOCOL_SIP, toCall));
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if(profileId != null) {
it.putExtra(SipProfile.FIELD_ACC_ID, profileId);
}
mContext.startActivity(it);
}
}
示例7: aggregateEvents
import android.database.Cursor; //导入方法依赖的package包/类
/**
* Iterates sqlite cursor and builds complete GameHarvest objects
*
* @param cursor sqlite cursor
* @param getDeletedImages
* @return List of GameHarvest objects
*/
private List<GameHarvest> aggregateEvents(Cursor cursor, boolean getDeletedImages) {
cursor.moveToFirst();
List<LogImage> logImages = new ArrayList<LogImage>();
boolean first = true;
int lastId = 0;
List<GameHarvest> logEvents = new ArrayList<GameHarvest>();
while (!cursor.isAfterLast()) {
int eventId = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_LOCALID));
if (!first && eventId != lastId) {
cursor.moveToPrevious();
logEvents.add(createEvent(cursor, logImages));
logImages = new ArrayList<LogImage>();
cursor.moveToNext();
}
LogImage image = logImageFromCursor(cursor, getDeletedImages);
if (image != null)
logImages.add(image);
lastId = eventId;
cursor.moveToNext();
first = false;
}
if (cursor.getCount() > 0) {
cursor.moveToLast();
logEvents.add(createEvent(cursor, logImages));
}
return logEvents;
}
示例8: getDisableApps
import android.database.Cursor; //导入方法依赖的package包/类
/**
* 获取主页停用列表apps
*
* @param tableName
* @return
*/
public List<AppInfo> getDisableApps(String tableName) {
final Cursor cursor = mSQLiteDatabase.rawQuery("SELECT * FROM " + tableName, null);
final List<AppInfo> list = new ArrayList<>();
try {
if (!cursor.moveToLast()) {
return list;
}
do {
AppInfo appInfo = new AppInfo();
appInfo.setAppPackageName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_PACKAGE_NAME)));
appInfo.setAppName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME)));
MyLogger.e(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME)));
appInfo.setAppIcon(CommonUtil.getImage(cursor.getBlob(cursor.getColumnIndex(AppInfo.APP_ICON))));
appInfo.setEnable(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_ENABLE)));
appInfo.setSystemApp(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_SYSTEM_APP)));
list.add(appInfo);
} while (cursor.moveToPrevious());
} finally {
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
return list;
}
示例9: moveToNext
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public boolean moveToNext() {
int count = getCount();
if (mPosition == count) {
return false;
}
if (mPosition == count - 1) {
mActiveCursor.moveToNext();
mPosition++;
return false;
}
int smallest = -1;
for (int i = 0, len = mCursors.length; i < len; i++) {
if (mCursors[i] == null || mCursors[i].getCount() == 0 || mCursors[i].isLast()) {
continue;
}
if (smallest == -1) {
smallest = i;
mCursors[smallest].moveToNext();
continue;
}
Cursor left = mCursors[smallest];
Cursor right = mCursors[i];
right.moveToNext();
int result = mComparator.compare(left, right);
if (result > 0) {
smallest = i;
left.moveToPrevious();
} else {
right.moveToPrevious();
}
}
mPosition++;
if (smallest != -1) {
mActiveCursorIndex = smallest;
mActiveCursor = mCursors[mActiveCursorIndex];
}
return true;
}
示例10: getMessages
import android.database.Cursor; //导入方法依赖的package包/类
private List<HashMap<String,String>> getMessages(String where, String[] whereArgs, int limitStart, int limitEnd){
Uri uri = Uri.parse("content://sms");
Cursor c = mContext.getContentResolver().query(uri,
null,
where,
whereArgs,
"date desc LIMIT "+String.valueOf(limitStart)+", "+String.valueOf(limitEnd)
);
List<HashMap<String,String>> ret = new ArrayList<HashMap<String, String>>();
if (c.getCount() > 0){
c.moveToLast();
for (int i = 0; i < c.getCount(); i++) {
String msgId = c.getString(c.getColumnIndex("_id"));
String address = c.getString(c.getColumnIndex("address")); // phone #
String date = c.getString(c.getColumnIndex("date"));
String body = c.getString(c.getColumnIndex("body"));
//String seen = c.getString(c.getColumnIndex("read"));
String type = c.getString(c.getColumnIndex("type"));
int thread = c.getInt(c.getColumnIndexOrThrow("thread_id"));
ContactsUtil mContacts = new ContactsUtil(mContext);
String contactId = mContacts.getContactId(address);
String name = address;
if (!(contactId == null)) {
HashMap<String, String> contact = mContacts.getContactById(Integer.parseInt(contactId));
name = contact.get("name");
}
HashMap<String,String> currMsg = new HashMap<>();
currMsg.put("address",address);
currMsg.put("name",name);
currMsg.put("date",date); //timestamp
currMsg.put("content",body);
currMsg.put("contact_id",contactId);
currMsg.put("type",type);
currMsg.put("msg_id", msgId);
currMsg.put("thread_id", String.valueOf(thread));
ret.add(currMsg);
c.moveToPrevious();
}
}
return ret;
}