我正在使用当前代码在线程中下载图像:
Log.d(TAG, "Fetching image: " + BASE_URL + mURL);
URLConnection connection;
InputStream input;
connection = (new URL(BASE_URL + mURL)).openConnection();
connection.setUseCaches(true);
connection.connect();
input = connection.getInputStream();
Bitmap image = BitmapFactory.decodeStream(input);
The 安卓文档 http://developer.android.com/reference/java/net/URLConnection.html不太清楚setUseCaches()方法是否会缓存数据。从测试来看,它看起来不像,但我想知道我是否做错了什么,是否有人知道 setUseCaches() 是否做了任何事情。
据我所知,使用 setUseCaches(true) 没有任何效果,并且不会缓存任何内容。在 Android 上缓存文件的推荐方法是将文件写入私有内部存储并使用 getCacheDir() 方法:
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)