cursor index out of bounds “index 0 requested: with size 0”

前端 未结 2 1737
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 02:05

I am getting cursor index out of bounds \"index 0 requested: with size 0\" error when I search my database for something. The item I am searching for in my database does not

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 02:50

    While you retrive value you have to use cursor.moveToNext;

    if (cursor.moveToFirst()){
       do{
          String data = cursor.getString(cursor.getColumnIndex("data"));
          // do what ever you want here
       }while(cursor.moveToNext());
    }
    

提交回复
热议问题