Cursor Index Out of Bounds Exception

两盒软妹~` 提交于 2019-12-01 00:35:43

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!