SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
This worked for me, you have to put it on your Main Activity.
try { Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize"); field.setAccessible(true); field.set(null, 100 * 1024 * 1024); //the 100MB is the new size } catch (Exception e) { e.printStackTrace(); }
Try this new constructor method above API 28. Maybe you should set a limited windowSizeBytes for CursorWindow and try-catch the exception.
Related cts code (https://android.googlesource.com/platform/cts/+/master/tests/tests/database/src/android/database/sqlite/cts/SQLiteCursorTest.java) :
public void testRowTooBig() { mDatabase.execSQL("CREATE TABLE Tst (Txt BLOB NOT NULL);"); byte[] testArr = new byte[10000]; Arrays.fill(testArr, (byte) 1); for (int i = 0; i < 10; i++) { mDatabase.execSQL("INSERT INTO Tst VALUES (?)", new Object[]{testArr}); } // Now reduce window size, so that no rows can fit Cursor cursor = mDatabase.rawQuery("SELECT * FROM TST", null); CursorWindow cw = new CursorWindow("test", 5000); AbstractWindowedCursor ac = (AbstractWindowedCursor) cursor; ac.setWindow(cw); try { ac.moveToNext(); fail("Exception is expected when row exceeds CursorWindow size"); } catch (SQLiteBlobTooBigException expected) { } }
Others:
Since this article was originally published, we’ve added new APIs in the Android P developer preview to improve the behavior above. The platform now allows apps to disable the ⅓ of a window heuristic and configure CursorWindow size.
Ref Link:https://medium.com/androiddevelopers/large-database-queries-on-android-cb043ae626e8