Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检查webview缓存中是否已存在文件_Android_Caching_Webview_Android Webview - Fatal编程技术网

Android 检查webview缓存中是否已存在文件

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

在我的应用程序中,我有一个带有网络视图的活动,其中加载了不同的图像。在加载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
但我想为所有设备找到解决方案,因此任何帮助都将不胜感激。。。webview缓存目录可能已更改?
谢谢

我终于找到了解决办法。我将我需要的手动保存在我的应用缓存目录中,当我必须再次加载它时,我会检查它是否在该目录中。该解决方案适用于所有android版本