[英]Android: IllegalStateException: Couldn't read row 24929, col 0 from CursorWindow
I need help with this error: 我需要这个错误的帮助:
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
In this code: 在这段代码中:
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();
}
This code works sometimes, but when I have many rows (like 25k rows) I get this Exception. 这段代码有时可以工作,但是当我有很多行(比如25k行)时,我会得到这个例外。 Is it a Android restriction?
这是Android限制吗?
Could you help me with that? 你能帮帮我吗? Thanks!
谢谢!
public ArrayList<Model> Name(){
ArrayList<Model> ModelList = new ArrayList<>();
db = getWritableDatabase();
Cursor c = db.rawQuery(" SELECT * FROM " + pTable,null );
while (c.moveToNext()){
String id = c.getString(0);
return ModelList;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.