【发布时间】:2013-06-27 15:50:52
【问题描述】:
在我的应用程序中,我有一个带有 webview 的活动,可以加载不同的图像。在加载 webview 之前,我需要知道图像是否已经缓存在 webview 缓存中。我发现这个适用于 2.3 及更低版本的 Android 设备的工作解决方案:
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
来自帖子“Is it possible to access the WebView cache?”,但我想找到适用于所有设备的解决方案,因此我们将不胜感激... webview 缓存目录可能已更改? 谢谢!
【问题讨论】:
标签: android caching webview android-webview