Skip to content

Instantly share code, notes, and snippets.

@Androguide
Last active December 25, 2015 18:49
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 Androguide/7023758 to your computer and use it in GitHub Desktop.
Save Androguide/7023758 to your computer and use it in GitHub Desktop.
Activer l'AppCache dans une WebView Android
public static void enableAppCache(WebView webView) {
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheMaxSize(1024*1024*8); // 8mb
// Apparemment il y a un bug puisque le path ci-dessous est sensé être le path par défaut
// et pourtant, bizarrement, l'AppCache ne fonctionnait pas sans le définir manuellement
webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
}
public static void enableCordovaAppCache(CordovaWebView webView) {
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
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