我每隔5秒访问一次数据库,如果我长时间停留在同一页面上,我会收到此错误。我不知道如何解决这个问题。我搜索了很多,但还没有找到解决方案。
以下是DbHelper中的代码(即dbca.android.myapp.Database.DBHelper.getGlobalData(DBHelper.java:165))
public ArrayList<TableGlobalDatat> getGlobalData() {
ArrayList<TableGlobalDatat> globalDataArrayList = new ArrayList<>();
try {
globalDatatArrayList = (ArrayList<TableGlobalDatat>) getGlobalDataDao().queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
return globalDatatArrayList;
}
logcat的:
E/AndroidRuntime: FATAL EXCEPTION: main
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
at android.database.CursorWindow.(CursorWindow.java:104)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:154)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:148)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
at com.j256.ormlite.android.AndroidCompiledStatement.getCursor(AndroidCompiledStatement.java:194)
at com.j256.ormlite.android.AndroidCompiledStatement.runQuery(AndroidCompiledStatement.java:72)
at com.j256.ormlite.stmt.SelectIterator.(SelectIterator.java:57)
at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:247)
at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:197)
at com.j256.ormlite.stmt.StatementExecutor.queryForAll(StatementExecutor.java:126)
at com.j256.ormlite.dao.BaseDaoImpl.queryForAll(BaseDaoImpl.java:248)
at dbca.android.myapp.Database.DBHelper.getGlobalData(DBHelper.java:165)
at dbca.android.myapp.network.SyncData.parseMessageList(SyncData.java:456)
at dbca.android.myapp.network.SyncData.access$500(SyncData.java:51)
at dbca.android.myapp.network.SyncData$10.onResponse(SyncData.java:427)
at dbca.android.myapp.network.SyncData$10.onResponse(SyncData.java:424)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:83)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:106)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5427)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)