I’m developing a small Android database app. Associated with the records in the database is a number of images (the image resolution will probably same as the screen on the device), there could be up to 20 images per record. Where would be the best place to store the images. I’m thinking either in the database itself or on the SD card. I’m pretty new to Android and as yet not really sure what I’m doing.
I’m developing a small Android database app. Associated with the records in the database
Share
While it’s possible to put the image itself in the database (as a blob) as far as I understand it’s not the best practice.
How big are the images you’re talking about? You said about the resolution of the screen, but with compression, they might be small enough.
If they’re fairly small, consider using the phone’s internal cache (found using getCacheDir() from a context). This also has the added bonus of allowing the user to delete the cache from the application menu, and your images will be private to your application. The Android documentation suggests approximately a 1MB cap on internal cache.
If they’re too big to store in the internal cache, the SD card may be your only option. The downside to this is those images will be visible to other applications, they can be deleted, removed, renamed, etc. You can’t guarantee they’ll be the way they were when you left them.