android - android.database.CursorWindowAllocationException: 512000 kb 的光标窗口分配失败:: 某些 android 设备中的问题
问题描述
当运行应用程序某些 android 设备时,它会显示错误
android.database.CursorWindowAllocationException: Cursor window allocation of 512000 kb failed. # Open Cursors=1 (# cursors opened by this proc=1)
at android.database.CursorWindow.<init>(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:140)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:134)
at com.material.components.database.tables.Tbl_BookList.getBookList(Tbl_BookList.java:110)
at com.material.components.fragment.FragmentHome$1.onResponse(FragmentHome.java:64)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:71)
读取 getMybookList() 函数时会出现问题。代码是
public List<BookList> getMyBookList() {
SQLiteDatabase db = DbHelper.getInstance().getReadableDatabase();
Cursor cursor = db.rawQuery("select * from " + TABLE_BOOK_LIST+ " where " + COL_BOOK_LIST_read + " = 1" , null);
List<BookList> callPriorityList = new ArrayList<>(cursor.getCount());
cursor.moveToFirst();
for (int i = 0; i < cursor.getCount(); cursor.moveToNext(), i++) {
BookList bookList = new BookList();
bookList.setId(cursor.getInt(cursor.getColumnIndex(COL_BOOK_LIST_id)));
bookList.setBook_title(cursor.getString(cursor.getColumnIndex(COL_BOOK_LIST_title)));
bookList.setBook_auther(cursor.getString(cursor.getColumnIndex(COL_BOOK_LIST_author)));
bookList.setCover_image(cursor.getString(cursor.getColumnIndex(COL_BOOK_LIST_cover)));
bookList.setBanner_image(cursor.getString(cursor.getColumnIndex(COL_BOOK_LIST_banner)));
bookList.setBook_description(cursor.getString(cursor.getColumnIndex(COL_BOOK_LIST_discription)));
callPriorityList.add(bookList);
}
cursor.close();
return callPriorityList;
}
解决方案
推荐阅读
- git - 删除 git 分支历史
- processing - 处理和 controlP5 - 当 Size 设置为变量值时按钮损坏
- python - 如何将函数应用于数据框中的每个元素?
- java - AWS Elastic Beanstalk SpringBoot fat WAR:找不到jsp
- dataframe - 如何将 sql.Dataframe 作为参数传递给 Scala 中的函数
- html - 如何不将样式应用于 CSS 中的特定元素?
- python - 计算 numpy 数组中具有 2 个或更多邻居的单元格数
- c - 全局变量属于c中的哪种存储类型?
- reinforcement-learning - Policy Gradient 与函数逼近的收敛保证
- javascript - 使用 Graphql 和 Gatsby Image 在 React/Gatsby 中使用 setInterval 更改图像