Best Practice when Caching files in Android

Viewed 7191

I currently have my app caching image files in the cache sub-directory for the application. The images are used in a ListView and stored in a HashMap of SoftReferences to Bitmaps.

So my question is this, what is the best way to cache these image files without inflating the space my application uses AND remains responsive from a user standpoint.

Things I am concerned about:

I know the user can clear the cache and that it is done automatically when space is low on internal memory, but I feel most users will see a several MB app and uninstall it. Also if the space is constantly low, my app will just keep downloading the images, making it appear slower.

Most devices have an SD card pre-installed, but what should I do when it is not inserted? The SD card may also be slower compared to internal storage, affecting my app's performance.

Should I include an option to choose the location of the cache?

Should I attempt to manage the size of my cache (be it in the /cache or /sdcard) or just forget about it?

Thank you for your time (its a long one I know) and please post any relevant experience.

3 Answers

Should I include an option to choose the location of the cache?

IMO: No, let make it more simplest as possible (Except you can include advance setting for expert user)

Should I attempt to manage the size of my cache (be it in the /cache or /sdcard) or just forget about it?

IMO: This is optional, it is double sword: your more work on background will help user more convenience but also more bug prone

Use 3rd libs: IMO using 3rd library as Picasso is better, it handle cache automatically by order: Memory cache -> Disk cache -> Network

Related