我有這樣的代碼,獲取最後一個ID如何使用sqlite檢索單個結果?
public int retrieveLastId() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("select "+ RECORDING_ID +" from " + DATABASE_TABLE + " ORDER BY "+ RECORDING_ID +" DESC LIMIT 1 ", null);
int last = 0;
last = Integer.parseInt(cursor.getString(0));
Log.e("sfsdlkfjs dfl sd",cursor.getString(0));
return last;
}
,但我得到一個錯誤android.database.cursorindexoutofboundsexception 我怎麼正確地返回了最後一個ID?
發佈您的logcat – 2015-02-11 02:35:14