-1

I have got SQLiteBlobTooBigException on huawei/honor Android 9.0 devices only. For 5k active installs. What the matter?

    String selectQuery = "SELECT  * FROM " + tableName;
    if(!db.isOpen()){db=this.getWritableDatabase();}
    Cursor cursor = db.rawQuery(selectQuery, null);
    i = cursor.getCount();

Other devices run well. image here

al ly
  • 11
  • 1

1 Answers1

0

As the message says, the Blob (byte[]) is too large to fit into a Cursor window (4MB). A cursor window being a buffer for the rows.

Blobs are not recommend because it Blob can be stored that are larger than size that can be retrieved using the SDK's SQLite API. That is there is no buffer as such when inserting a row, so the size restriction doesn't apply.

The resolution is to save the byte[] in a file and to then save the path to the file in the database.

MikeT
  • 51,415
  • 16
  • 49
  • 68
  • **Other devices run well. Why?** – al ly Oct 01 '19 at 14:35
  • @ally I don't know why but they are obviously different in some way resulting in either larger Blobs or that somehow they reduce the Cursor Window size. I believe the former is the more likely. If you apply the suggested resolution then why becomes irrelevant. – MikeT Oct 01 '19 at 23:06
  • 1. Your way requires additional permission for app. 2. Here [https://stackoverflow.com/questions/57726838](https://stackoverflow.com/questions/57726838/getting-random-android-database-sqlite-sqliteblobtoobigexception) is similar , but there is not Byte[]. 3. Looks like battle Google vs Huawei – al ly Oct 02 '19 at 17:16