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

来源:互联网 发布:python可以开发软件吗 编辑:程序博客网 时间:2024/04/29 14:29

java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.

IllegalState:非法状态。在调用cursor查询数据库是出现此错误。返回的值是-1,说明没找到这个字段。

首先查询:

if (cursor.moveToFirst()) {    do {        // your content    } while (cursor.moveToNext());}

把上面的代码改为下面的:

while (cursor.moveToNext()) {        // your content}

Like this.

如果还不行,就可能是数据库的问题。检查一下数据库。
0 0
原创粉丝点击