什么是缓存图像的理想场所? [英] What is the ideal place to cache images?

查看:133
本文介绍了什么是缓存图像的理想场所?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从远程服务器获取大量的缩略图,在我的应用程序,并以列表形式显示延迟加载这些。

I am fetching a lot of thumbnails in my application from a remote server and lazy-loading these in a list view.

图片取指运行在后台AsynTask和建成后所获取的图像是使用SoftReferences存储在一个HashMap。

The image fetches run in a background AsynTask and when completed the fetched images are stored in a HashMap using SoftReferences.

这工作得很好,但是当在高速缓存中的图像被GC'd中,取必须重新运行。

This works just fine but when the images in the cache gets GC’d, the fetches have to be rerun.

我可以将它们存储在SD卡上,这样就没有再取。

I could have stored them on the SD card so there would be no re-fetching.

不过,我并没有采取这种方法的混乱,因为这会造成在SD卡上。

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?

什么是理想之地缓存图像?任何意见,比如项目,或指针将AP preciated。

What is the "ideal place" to cache images? Any advice, example projects, or pointers would be appreciated.

推荐答案

您应该检查文件的数据存储选项:
<一href="http://developer.android.com/guide/topics/data/data-storage.html">http://developer.android.com/guide/topics/data/data-storage.html
文件被保存在应用程序目录,所以没有乱七八糟的任何地方。文件将与应用程序最终被删除。您也可以实现一些方法,将清除缓存,当应用程序启动(例如删除旧超过2周文件)。

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).

这篇关于什么是缓存图像的理想场所?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆