I am using a sqlite DB to store my users location while they are online, but for some reason I am getting this crash report and I don't know what it is or how to fix it.
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
at android.database.CursorWindow.<init>(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at com.tech.databases.Routes_DB.savedGPSHasEntries(Routes_DB.java:109)
at com.tech.activity.Menu_dashboard.onLocationChanged(Menu_dashboard.java:2602)
at com.google.android.gms.c.b.r.a(Unknown:-1)
at com.google.android.gms.common.api.internal.h.b(Unknown:-1)
at com.google.android.gms.common.api.internal.h$c.handleMessage(Unknown:-1)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6314)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Every thing I have looked up says that it is caused by not closing my cursor, but on my code I close it every single time:
public boolean savedGPSHasEntries(){
boolean hasEntry = false;
String countQuery = "SELECT * FROM " + TABLE_SAVED_ROUTE;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int cnt = cursor.getCount();
if (cnt > 0)
hasEntry = true;
// Log.e("Database", "Count: " + cnt);
cursor.close();
return hasEntry;
}
And this is how I query the data:
if (routesDB.savedGPSHasEntries()) {
Log.e(TAG, "DB isn't empty");
}
So I am confused about this error or how to even begin to find out how to fix it.