【发布时间】:2016-11-29 02:56:57
【问题描述】:
我需要有关此错误的帮助:
Fatal Exception: java.lang.IllegalStateException: Couldn't read row 24929, col 0 from CursorWindow.
Make sure the Cursor is initialized correctly before accessing data from it
在这段代码中:
SQLiteDatabase db = getReadableDatabase();
Cursor res = db.rawQuery("select id from " + pTable, null);
if (res != null) {
if (res.getCount() != 0) {
res.moveToFirst();
int id;
while (!res.isAfterLast()) {
id = res.getInt(res.getColumnIndex("id")); // <-- Error was here
// ...
res.moveToNext();
}
}
res.close();
}
此代码有时有效,但当我有很多行(如 25k 行)时,我会收到此异常。 是安卓限制吗?
你能帮我解决这个问题吗? 谢谢!
【问题讨论】:
-
试试这个 -
if (res != null) { int id; while (res.moveToNext()) { id = res.getInt(res.getColumnIndex("id")); // <-- Error was here // ... } res.close(); } -
一张表的理论最大行数为(18446744073709551616或1.8e+19左右)
-
您的表可能没有
id列?
标签: android sqlite illegalstateexception