I am planning to cache the images from a server and use show it as a sort slide show in my App. I would be asynchronously loading the images.
I have two options:
Which one would be better?
Please let me know if you you have any kind of suggestions regarding caching images.
The bitmap cache stores decoded images as Android Bitmap objects. These are ready for display or postprocessing. On Android 4. x and lower, the bitmap cache's data lives in the ashmem heap, not in the Java heap.
Image caching essentially means downloading an image to the local storage in the app's cache directory (or any other directory that is accessible to the app) and loading it from local storage next time the image loads.
Feb 27, 2019. Image caching is an interesting and a very important concept to understand, especially for mobile developers. In many mobile apps, we deal with a lot of images and assets, and we are also required to show all these images to the user as quickly as possible.
Your second approach has 2 major flaws:
I'd suggest saving images to files right after you download them and keep in memory reasonable number of images you need to show without visible delay (loading extra images when required and disposing of unnecessary ones)
I would recommend you the first option. Leaves you more flexibility, e.g. when the data size increases the memory size.
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