我知道这个老问题,但我找不到问题的解决方案 android.database.CursorWindowAllocationException:2048 kb的游标窗口分配失败。
这是我的代码:
public synchronized String getType(String suffix) {
String basicSuffix = suffix.toLowerCase();
String countQuery = SQL_SELECT_ALL + TABLE_TYPE + SQL_WHERE + KEY_TYPE_SUFFIX + " =? ";
Cursor cursor = null;
String type = "";
try {
SQLiteDatabase db = this.getReadableDatabase();
cursor = db.rawQuery(countQuery, new String[]{basicSuffix});
if (cursor != null) {
cursor.moveToFirst();
if (cursor.getCount() > 0 && cursor.getString(1) != null) {
type = cursor.getString(1);
} else {
type = FILE_TYPE_UNKNOWN;
}
} else {
type = FILE_TYPE_UNKNOWN;
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return type;
}
记录行代码cursor.movetoFirst();
谢谢。