Android 检查webview缓存中是否已存在文件
在我的应用程序中,我有一个带有网络视图的活动,其中加载了不同的图像。在加载webview之前,我需要知道图像是否已经缓存在webview缓存中。我找到了适用于2.3 android设备和更低版本的有效解决方案:Android 检查webview缓存中是否已存在文件,android,caching,webview,android-webview,Android,Caching,Webview,Android 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
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缓存目录可能已更改?
谢谢 我终于找到了解决办法。我将我需要的手动保存在我的应用缓存目录中,当我必须再次加载它时,我会检查它是否在该目录中。该解决方案适用于所有android版本