4

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

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!

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

1 Answers1

0

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.

jprog
  • 155
  • 1
  • 2
  • 12