I can guarantee that the database has all the columns and values I am looking for.
The query comes back with a CursorOutOfBounds
. Does anyone have any ideas why and what I should test?
Cursor c = db.rawQuery("SELECT * FROM table WHERE _id="+nextvalue+"" , null);
c.moveToFirst();
numval = c.getInt(c.getColumnIndex("_id"));
c.close();
Logcat output
11-22 00:08:36.614: ERROR/AndroidRuntime(25405): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
The query is returning an empty result set. There are no records with the id of nextvalue
(whatever that is). You should check that moveToFirst()
succeeded:
if (c.moveToFirst()) {
numval = c.getInt(c.getColumnIndex("_id"));
} else {
// no results returned
}
c.close();
Does the statement is in bindview
of CursorAdapter ? if it is, try to remove c.moveToFirst()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.