Access Large BLOB in Android Sqlite without Cursor

末鹿安然 提交于 2019-11-30 07:37:34
Bms270

As CL mentioned, using NDK is indeed a way to access Sqlite natively via C language in Java language. However I realized it could get really messy if I wanted to write a custom wrapper myself and try to access the functions in Java.

After searching around, I came across a brilliant open source project called Sqlite4java which is a tight wrapper around Sqlite, compiled to use on various platforms including Android. This library allows you to interact with Sqlite without using Android Cursor which removes the limitations.

I am able to retrieve 20 MB of Blob in 480 milliseconds. This is even faster than reading a small record from Sqlite via Cursors. I believe this can be used to enhance any query to Sqlite by skipping the use of Cursor. Here's the link to this great library: http://code.google.com/p/sqlite4java/

Android's Java API always has the 1 MB limit.

You should not store BLOBs of that size in the database; the file system is more efficient at handling them.

If you really want to use BLOBs, you have to go through the NDK to access the C API directly.

Randy Sugianto 'Yuku'

There is actually a solution without resorting to a different implementation of SQLite wrapper for Android!

Retrieve large blob from Android sqlite database

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