Cursor size limit in Android SQLiteDatabase

試著忘記壹切 提交于 2019-11-26 15:26:22

There's a limit of 1MB on internal assets due to dynamic decompression; the 1MB limit also seems to apply to Cursor blobs but this doesn't seem to be documented anywhere.

Generally you should avoid blobs in SQLite as they perform poorly; instead save the blob data as a file and store the location of the file in your DB.

Reading a BLOB that is less than 100KB from a SQLite database is faster than reading the same from the file system. However, anything greater than that is best kept on the disk, with a reference in the db. More at: http://www.sqlite.org/intern-v-extern-blob.html

There is a 1MB limit per operation. (I am unsure if this is per row, or per column in the case of SQLite queries). The limit is due to the SQLite API interacting with sqlite out-of-process over the Binder/Parcel IPC system. The same limit applies for values within a Bundle (Intent extras, for instance).

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process.

See: http://developer.android.com/reference/android/os/TransactionTooLargeException.html

Is the query you're using 'selecting' said blob? Can you omit it? If you can't, are you using:

 blob = rs.getBlob(column) ;
 InputStream in = blob.getBinaryStream();

or

 blob.getBytes(1, lengthOblob) ;

The first method will let you read the blob in chunks. The second is going to have the blob loaded all at once.

Looks like BLOB support in Android isn't implemented yet...

http://www.basic4ppc.com/forum/basic4android-updates-questions/6648-support-sqlite-blob.html

What data is stored in the BLOB fields? I would guess pictures.

I would recommend NOT using BLOBs. The file system is a much better choice for binary data.

Can you explain a bit more about what you want to accomplish with the database?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!