`

重用WebView的cache图片文件

 
阅读更多
如何从WebView使用的cache文件夹中重复使用一些图片资源:
/** 从缓存里读取图片 */
	public Bitmap getPictureFromCache() {
		Bitmap bitmap = null;
		File file = new File(getCacheDir() + "/webviewCache/10d8d5cd");
		try {
			FileInputStream is = new FileInputStream(file);
			bitmap = BitmapFactory.decodeStream(is);

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return bitmap;
	}
分享到:
评论
2 楼 joyhub2140 2012-02-23  
如果查询webview的缓存数据库的话,很麻烦,会出现database is locked。最好能知道他的缓存文件的命名方式。
1 楼 univasity 2011-09-17  
cache中保存的文件名与原文件的名字不对应的吧?需要进一步读取webviewCache.db才能进行匹配查找吧?

相关推荐

Global site tag (gtag.js) - Google Analytics