I want to store sample images. what is the best efficient way weather to store on SD card or in DB?
Inorder to store images to android SQLite database, you need to convert the image uri to bitmap then to binary characters that is, bytes[] sequence. Then set the table column data type as BLOB data type. After retrieving the images from DB, convert the byte[] data type to bitmap in order to set it to imageview.
The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.
Maximum Database Size The maximum size of a database file is 4294967294 pages. At the maximum page size of 65536 bytes, this translates into a maximum database size of approximately 1.4e+14 bytes (281 terabytes, or 256 tebibytes, or 281474 gigabytes or 256,000 gibibytes).
if the images are not big(2-3 KB) and the collection of them is not supposed to be expanded then you can save them to db. But it would be harder to write them, read them. On the other hand the user won't be able to do anything with them.
Otherwise, if you want to let user to expand the image collection or the images are rather big you should store them to sd card.
Anyway, you should be aware of space lackness and treat those cases appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With