Android sqlite / BLOB perfomance issue

旧时模样 提交于 2019-11-30 05:28:14

Your first solution is better one, Use a file from sdcard and store the reference path in your sqlite database, This gives you faster performance and also your database is remain light weight.

I don't have the reputation yet to comment an answer, so I'll add my 2cts as an answer instead, please forgive me.

I was looking for an answer to a similar question and I don't think the current answer is satisfying because if you ask SQLite.org they'll tell you that it depends on the blob size and on the page size.

They have done a benchmark - not on android though - that shows that storing blobs in SQLite is faster for small blobs (up to 20kB) than storing on separate files. For blobs greater than 100kB though, the performance drop is big and it's better storing the blobs in separate files as you ( user370605 ) recommend. See http://www.sqlite.org/intern-v-extern-blob.html

I'll consider the question not answered regarding Android.

I have not enough reputation to do comments as well. I'm adding this answer to help anyone who still looking for some suggestion. After several years hardware improvement, performance of that two solutions have little difference. I've tried several times in my Nexus 6p writing an about 2 MB image binary to SQLite only takes 50 ms in average. Even though external storage will perform better, current performance can meet my expectation. Write to SQLite do not need WRITE_EXTERNAL_STORAGE permission which may be revoke if permission granted from other apps. In this case, SQLite can be a good choice.

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