Cursor Index Out of Bounds Exception

前端 未结 2 1574
Happy的楠姐
Happy的楠姐 2021-01-07 01:44

In attempting to execute a query on my database, I get this exception. However, the documentation states that the method SQLiteDatabase.query(...) returns, \"A

2条回答
  •  隐瞒了意图╮
    2021-01-07 02:12

    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

提交回复
热议问题