I am fetching a lot of thumbnails in my application from a remote server and lazy-loading these in a list view.
The image fetches run in a background AsynTask and when completed the fetched images are stored in a HashMap using SoftReferences.
This works just fine but when the images in the cache gets GC’d, the fetches have to be rerun.
I could have stored them on the SD card so there would be no re-fetching.
But I did not take this approach because of the clutter it would create on the SD card.
Are there perhaps alternatives to these sorta like temporary folders that can be cleared when activity/app finishes/exits?
What is the “ideal place” to cache images? Any advice, example projects, or pointers would be appreciated.
You should check files data storage options:
http://developer.android.com/guide/topics/data/data-storage.html
Files are being saved in the applications directory, so there is no mess anywhere. Files will be finally removed with the app. You can also implement some method which will clear the cache when the app starts (for example remove files older than 2 weeks).