【发布时间】:2011-12-10 04:52:51
【问题描述】:
我有一个可以访问网页的 WebView。是否有可能,当我离线时可以访问例如以前下载的图像? 如果可能的话,我该怎么做?
提前致谢。
【问题讨论】:
-
下载是指已查看?如果你下载到手机/平板电脑上,你应该可以去你的画廊看到它们
标签: android caching webview android-webview browser-cache
我有一个可以访问网页的 WebView。是否有可能,当我离线时可以访问例如以前下载的图像? 如果可能的话,我该怎么做?
提前致谢。
【问题讨论】:
标签: android caching webview android-webview browser-cache
是的,您可以,至少对于 Android 2.3 及更低版本。
如果你想查看整个缓存文件夹,它位于这里:
<android cache dir>/<your app package>/cache/webviewCache/
如果您已经知道缓存图像的 URL,则可以获取实际文件:
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
【讨论】:
如果其他人遇到这个问题,我也遇到了类似的问题,我手动管理(保存和检索)我的应用缓存来解决它。 Here it is我的相关帖子。
【讨论】:
shouldinterceptrequest拦截了所有内容
【讨论】: