Last active
December 25, 2015 18:49
-
-
Save Androguide/7023758 to your computer and use it in GitHub Desktop.
Activer l'AppCache dans une WebView Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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