Make sure the Cursor is initialized correctly before accessing data from it

详细错误是:java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.

出现这个原因是因为我在获取Cursor中的字段时,获取了一个不存在的字段,例如,我原本要获取数据库book表中的bookId字段,结果获取的时候写成了bookiD,

while (cursor.moveToNext()) {  
 int bookId = cursor.getInt(cursor.getColumnIndex("bookiD"));
}

注意:Android是区分大小写的,所以我们在获取的时候也要严格按照数据库表字段的大小写来获取数据

 



相关文章:

  • 2021-10-25
  • 2021-04-03
  • 2022-12-23
  • 2021-11-25
  • 2021-11-05
  • 2022-01-02
  • 2022-01-12
猜你喜欢
  • 2022-01-15
  • 2021-11-09
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案