Skip to content

Instantly share code, notes, and snippets.

@Williammer
Forked from jaydeepw/enableHTML5AppCache.java
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Williammer/6496f77f93d808e35337 to your computer and use it in GitHub Desktop.
Save Williammer/6496f77f93d808e35337 to your computer and use it in GitHub Desktop.
private void enableHTML5AppCache() {
webView.getSettings().setDomStorageEnabled(true);
// Set cache size to 8 mb by default. should be more than enough
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
// This next one is crazy. It's the DEFAULT location for your app's cache
// But it didn't work for me without this line
webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment