开发者

What is the best practice to cache images on Android?

开发者 https://www.devze.com 2023-01-02 13:55 出处:网络
In my application I use SoftReference to cache images, it is working fine with active internet connection. And now I need to cache images, so I could use it in offline mode.

In my application I use SoftReference to cache images, it is working fine with active internet connection. And now I need to cache images, so I could use it in offline mode.

What is the best way to implement it? Use complex solution with SoftReference and database? or maybe SoftReference 开发者_运维技巧and local storage (sdcard)?

I would appreciate your advices. Thanks.


2 level cache in memory and on disk. Check out the https://github.com/mttkay/droid-fu project on github. It contains an ImageCache that works this way.


Late answer, But I hope it still counts for something. ImageDownloader is the best one for the job. I also found a slight variation of the class at:

http://theandroidcoder.com/utilities/android-image-download-and-caching/

The main difference between the two is that the ImageDownloader uses the Android caching system, and the modified one uses internal and external storage as caching, keeping the cached images indefinitely or until the user removes it manually. The author also mentions Android 2.1 compatibility.

Regards, EZFrag

0

精彩评论

暂无评论...
验证码 换一张
取 消