是否有可能访问的WebView缓存? [英] Is it possible to access the WebView cache?

查看:126
本文介绍了是否有可能访问的WebView缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web视图中,我可以访问网页。是否有可能,当我脱机访问,例如到已经previously下载的图片吗? 而且如果可能的话我该怎么办呢?

I have a WebView in which I can access to web pages. Is it possible, when I am offline to have access for example to the images that have been previously downloaded? And if it is possible how can I do this?

在此先感谢。

推荐答案

是的,你可以,至少在Android 2.3的低。

Yes, you can, at least for Android 2.3 and lower.

如果你想看到整个缓存文件夹,它是坐落于此:

If you want to see the entire cache folder, it is situated here:

<android cache dir>/<your app package>/cache/webviewCache/

如果你已经知道缓存图片的网址,就可以得到实际的文件,以便:

If you already know the URL of the cached image, you can get the actual file so:

String uri = "http://the url of the image that you need";
String hashCode = String.format("%08x", uri.hashCode());
File file = new File(new File(getCacheDir(), "webviewCache"), hashCode);
// if the call file.exist() returns true, then the file presents in the cache

这篇关于是否有可能访问的WebView缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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