In attempting to execute a query on my database, I get this exception. However, the documentation states that the method SQLiteDatabase.query(...)
returns, \"A
After query you need to call next()
or moveToFirst()
. Cursors are lazy loaded, after calling these methods cursor is loaded into memory. You can decide when to do it.
to iterate trough all rows:
Cursor c = db.query(TABLENAME, null, null, null, null, null, null);
while(c.moveToNext()) {
int id = c.getInt(c.getColumnIndex("_ID"));
}
or you can use other cursor functions, for example moveToPosition() to access row specified by id
more info: http://developer.android.com/reference/android/database/Cursor.html