Android Image Storage

I am developing a small Android application. Associated with entries in the database is the number of images (the image resolution is probably the same as on the screen on the device), there can be up to 20 images per recording. Where will be the best place to store images. I think either in the database itself or on the SD card. I am new to Android and not quite sure what I am doing.

+4
source share
2 answers

Although you can put an image in a database (like a blob), as I understand it, this is not the best practice.

How big are the images you are talking about? You said about screen resolution, but with compression, they can be quite small.

If they are quite small, consider using the phoneโ€™s internal cache (found using getCacheDir () from the context). It also gives an added bonus, allowing the user to remove the cache from the application menu, and your images will be closed to your application. The Android documentation offers approximately 1 MB of cap for the internal cache.

If they are too large to be stored in the internal cache, an SD card might be your only option. The disadvantage of this is that the images will be visible to other applications, they can be deleted, deleted, renamed, etc. You cannot guarantee that they will be what they were when you left them.

+4
source

In my application, I was forced to store images in SQLite as a blob. SQLite's Blob size is theoretically limited to two gigabytes - but manual recommends using only a few megabytes of size. So I do image storage. In terms of performance - everything is fine

In any case, I am sure that storing images in a database is more attractive than other exotic methods. For instance. no one can predict the capacity of an SD card or even its presence on board.

+3
source

All Articles