Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to access the WebView cache?

I have a WebView in which I can access to web pages. Is it possible, when I am offline to have access for example to the images that have been previously downloaded? And if it is possible how can I do this?

Thanks in advance.

like image 991
flyhalf8610 Avatar asked Nov 25 '22 08:11

flyhalf8610


1 Answers

Yes, you can, at least for Android 2.3 and lower.

If you want to see the entire cache folder, it is situated here:

<android cache dir>/<your app package>/cache/webviewCache/

If you already know the URL of the cached image, you can get the actual file so:

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
like image 115
vortexwolf Avatar answered Dec 04 '22 05:12

vortexwolf