On Android devices up to and including 4.4.2, the default Browser and Chrome support the HTML5 cache manifest. However, on those same devices, the WebView component does not seem to support the HTML5 cache manifest. Does anybody know how I can make the WebView component support the HTML5 manifest?
This example demonstrate about How to enable app cache for webview in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
The Url record we requested is stored in webviewCache. db, and the content of the URL is stored in the webviewCache folder. There are two caches in WebView: Web data caching (storing opened pages and resources) and H5 caching (AppCache).
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With