Java Code Examples for android.database.Cursor.move()

The following are Jave code examples for showing how to use move() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: weex-3d-map   File: HistoryManager.java   Source Code and License Vote up 6 votes
public HistoryItem buildHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getReadableDatabase();
    cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    String text = cursor.getString(0);
    String display = cursor.getString(1);
    String format = cursor.getString(2);
    long timestamp = cursor.getLong(3);
    String details = cursor.getString(4);
    Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
    return new HistoryItem(result, display, details);
  } finally {
    close(cursor, db);
  }
}
 
Example 2
Project: weex-3d-map   File: HistoryManager.java   Source Code and License Vote up 6 votes
public void deleteHistoryItem(int number) {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(number + 1);
    db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + cursor.getString(0), null);
  } finally {
    close(cursor, db);
  }
}
 
Example 3
Project: weex-3d-map   File: HistoryManager.java   Source Code and License Vote up 6 votes
public void trimHistory() {
  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  Cursor cursor = null;
  try {
    db = helper.getWritableDatabase();      
    cursor = db.query(DBHelper.TABLE_NAME,
                      ID_COL_PROJECTION,
                      null, null, null, null,
                      DBHelper.TIMESTAMP_COL + " DESC");
    cursor.move(MAX_ITEMS);
    while (cursor.moveToNext()) {
      String id = cursor.getString(0);
      Log.i(TAG, "Deleting scan history ID " + id);
      db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + id, null);
    }
  } catch (SQLiteException sqle) {
    // We're seeing an error here when called in CaptureActivity.onCreate() in rare cases
    // and don't understand it. First theory is that it's transient so can be safely ignored.
    Log.w(TAG, sqle);
    // continue
  } finally {
    close(cursor, db);
  }
}
 
Example 4
Project: letv   File: WorldCupTraceHandler.java   Source Code and License Vote up 5 votes
public DownloadDBBean getDownloadDBBeanPosition(int position) {
    DownloadDBBean mDownloadDBBean = null;
    try {
        Cursor cursor = this.context.getContentResolver().query(LetvContentProvider.URI_WORLDCUPTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
        if (cursor.move(position + 1)) {
            mDownloadDBBean = createDownloadDBBean(cursor);
        }
        LetvTools.closeCursor(cursor);
        return mDownloadDBBean;
    } catch (Throwable th) {
        LetvTools.closeCursor(null);
    }
}
 
Example 5
Project: letv   File: DownloadTraceHandler.java   Source Code and License Vote up 4 votes
public DownloadDBBean getDownloadDBBeanPosition(int position) {
    Throwable th;
    Cursor cursor = null;
    DownloadDBBean mDownloadDBBean = null;
    try {
        cursor = this.mContext.getContentResolver().query(LetvContentProvider.URI_DOWNLOADTRACE, null, "finish<>?", new String[]{"4"}, "timestamp ASC");
        if (cursor.move(position + 1)) {
            DownloadDBBean mDownloadDBBean2 = new DownloadDBBean();
            try {
                mDownloadDBBean2.vid = cursor.getInt(cursor.getColumnIndex("episodeid"));
                mDownloadDBBean2.aid = cursor.getInt(cursor.getColumnIndex(PageJumpUtil.IN_TO_ALBUM_PID));
                mDownloadDBBean2.icon = cursor.getString(cursor.getColumnIndex(SettingsJsonConstants.APP_ICON_KEY));
                mDownloadDBBean2.type = cursor.getInt(cursor.getColumnIndex("type"));
                mDownloadDBBean2.ord = (float) cursor.getInt(cursor.getColumnIndex("ord"));
                mDownloadDBBean2.cid = cursor.getInt(cursor.getColumnIndex("cid"));
                mDownloadDBBean2.episodetitle = cursor.getString(cursor.getColumnIndex("episodetitle"));
                mDownloadDBBean2.episodeIcon = cursor.getString(cursor.getColumnIndex("episodeicon"));
                mDownloadDBBean2.albumtitle = cursor.getString(cursor.getColumnIndex(DownloadAlbumTable.COLUMN_ALBUMTITLE));
                mDownloadDBBean2.totalsize = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_TOTALSIZE));
                mDownloadDBBean2.finish = cursor.getInt(cursor.getColumnIndex("finish"));
                mDownloadDBBean2.timestamp = cursor.getLong(cursor.getColumnIndex("timestamp"));
                mDownloadDBBean2.length = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_LENGTH));
                mDownloadDBBean2.filePath = cursor.getString(cursor.getColumnIndex("file_path"));
                mDownloadDBBean2.isHd = cursor.getInt(cursor.getColumnIndex("isHd"));
                mDownloadDBBean2.isNew = cursor.getInt(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ISNEW));
                mDownloadDBBean2.btime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_BTIME));
                mDownloadDBBean2.etime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ETIME));
                mDownloadDBBean = mDownloadDBBean2;
            } catch (Throwable th2) {
                th = th2;
                mDownloadDBBean = mDownloadDBBean2;
                LetvTools.closeCursor(cursor);
                throw th;
            }
        }
        LetvTools.closeCursor(cursor);
        return mDownloadDBBean;
    } catch (Throwable th3) {
        th = th3;
        LetvTools.closeCursor(cursor);
        throw th;
    }
}