Android:IllegalStateException:无法从游标窗口读取第24929行第0列
我需要有关此错误的帮助:Android:IllegalStateException:无法从游标窗口读取第24929行第0列,android,sqlite,illegalstateexception,Android,Sqlite,Illegalstateexception,我需要有关此错误的帮助: 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 re
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行时,我会得到这个异常。
这是安卓系统的限制吗
你能帮我吗?
谢谢 试试这个-如果有的话!=null{int id;而res.moveToNext{id=res.getIntres.getColumnIndexid;//表中理论最大行数为18446744073709551616或约1.8e+19您的表可能没有id列?
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;
}