I'have started making android quiz game ,So I have 500 images for question but i don't know where should i store it ,I watch some videos on internet they store their image in Drawable-Floder and use some code to make image show in activity but in those videos they have a few images . My question is "It is good to store 500 images in drawable floder, or Should I use database (I don't know much about database So i don't know how to store images and how to show image from database to activity)
2 Answers
First, at all it is wrong to store images on Database, It will make your app slowly.
You can save your images on drawable
folder, but it will make your app size large on the store.
So, I suggest building an API
so you can download them from the internet and store them on internal storage.

- 2,926
- 22
- 27
-
It is mean when someone install app it will automatic download images from internet ? But I want to make offline app – VaTh Temple Oct 06 '19 at 09:13
-
You can try compressing the resources and uncompress them on first load – bradm6s Oct 06 '19 at 09:42
-
You can easily cache your images. – Amjad Alwareh Oct 06 '19 at 10:43
One of the most important aspects is the image sizes. If the images are small say around 100k then storing them in the database can be efficient as per 35% Faster Than The Filesystem.
If they are larger then storing them in the database will start to get progressively less efficient. At around 2Mb without code to split them (adding even more inefficiency) into manageable chunks, then they become impossible to use in Android when using the SDK as they cannot be retrieved due to a Cursor Window being limited to 2Mb.
So if the 500 images were around 100k each then that would be approximately 25Mb probably managable stored in the database and probably quite efficient, although at only 9 rows per Cursor Window pushing it a little.
At 500k that's 125Mb and the 100Mb playstore limitation would be crossed. This would need APK Expansion files (see link below), it would likely be very inefficient storing them in the database (probably 3 rows per Cursor Window).
You would then be retrieving the images from the assets or raw folder or perhaps another folder and storing the path or part of the path in the database, if all images were in the same location and just the image name were different then just storing the image name may suffice so say 25 characters (bytes) per image, database wise is not a lot at all at around 15k. APK Expansion Files
You may wish to have a look at How can I insert image in a sqlite database which includes demo code that saves images 100k or less in the database and those over 100k it saves the path.

- 51,415
- 16
- 49
- 68