检查文件是否已经存在于web视图缓存的android [英] Check if file already exists in webview cache android

查看:110
本文介绍了检查文件是否已经存在于web视图缓存的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序我有一个web视图至极加载不同的图像的活动。在加载web视图,我需要知道如果图像已经缓存在web视图缓存。我已经找到了为2.3 Android设备,这有效的解决方案更低的:

In my app I have an activity with a webview wich loads different images. Before loading the webview, I need to know if the image is already cached in the webview cache. I've found this working solution for 2.3 android devices and lower:

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

从后是否有可能访问web视图缓存?但我想找到的所有设备的解决方案,所以任何帮助将AP preciated ......五月的WebView缓存目录中有哪些变化? 谢谢!

from the post "Is it possible to access the WebView cache?" but I would like to find the solution for all devices, so any help will be appreciated... May webview cache directory have changed? Thanks!

推荐答案

最后,我已经找到了解决办法。我救了我需要手动在我的应用程序缓存目录中,而当我再次加载它,我检查,如果它是一个目录中。该解决方案适用于所有的Andr​​oid版本。

Finally I've found a workaround. I save what I need manually in my app cache directory, and when I have to load it again I check if it is inside that directory. That solution works on all android versions.

这篇关于检查文件是否已经存在于web视图缓存的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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