java - java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow

試著忘記壹切 提交于 2019-11-30 20:49:34

Your subject line is misleading. The exception in your stacktrace says

Couldn't read row 0, col -1 from CursorWindow

which essentially means that getColumnIndex() could not find the specified column in the Cursor and -1 was returned as column index.

Your selection SELECT * contains all columns from the table.

Your CREATE TABLE seems to contain all columns you're requesting the index of with getColumnIndex() in getNotes().

Chances are that you've added a column but the test device still has a database file without that column. Just uninstall your app or clear its data to remove the old database file and make your onCreate() recreate the database on the next run.

There can be a difference between the column name in the table and the name you are giving to access that column in your code. So you should recheck the name, because in my case there was a spelling mistake :P

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