安卓图片缓存 [英] Android image caching
本文介绍了安卓图片缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从网络下载图像后如何缓存?
How can I cache images after they are downloaded from web?
推荐答案
现在重点:使用系统缓存.
And now the punchline: use the system cache.
URL url = new URL(strUrl);
URLConnection connection = url.openConnection();
connection.setUseCaches(true);
Object response = connection.getContent();
if (response instanceof Bitmap) {
Bitmap bitmap = (Bitmap)response;
}
提供内存和闪存缓存,与浏览器共享.
Provides both memory and flash-rom cache, shared with the browser.
呸.我希望有人在我编写自己的缓存管理器之前告诉我这一点.
grr. I wish somebody had told ME that before i wrote my own cache manager.
这篇关于安卓图片缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文