5

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.

flyhalf8610
  • 94
  • 2
  • 8
  • By download you mean viewed? if you downloaded to the phone/tablet you should be able to go to your gallery and see them – AAlferez May 08 '14 at 18:16

3 Answers3

1

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
vortexwolf
  • 13,967
  • 2
  • 54
  • 72
0

If someone else faces this problem, I had a similar issue and I solve it managing(saving and retrieving) my app cache manually. Here it is my related post.

Community
  • 1
  • 1
jprog
  • 155
  • 1
  • 2
  • 12
-1

CacheManager: http://developer.android.com/reference/android/webkit/CacheManager.html

Grantland Chew
  • 2,620
  • 26
  • 26
  • Just an FYI, CacheManager was deprecated as of ICS and was removed in 4.2. http://developer.android.com/sdk/api_diff/17/changes/pkg_android.webkit.html (And the above link yields a 404). – Vito Andolini Jan 02 '13 at 23:15