In my android webview my webpage is loading even without internet because of cache, so i want to disable cache in android webview, can anyone help me how to do this?
I am using following lines in my webview, but still i am not able to disable cache.
myBrowser.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); myBrowser.getSettings().setAppCacheEnabled(false);
Please suggest me if there are some other methods
setAppCacheEnabled(false); webview. getSettings(). setCacheMode(WebSettings. LOAD_NO_CACHE);
There are two caches in WebView: Web data caching (storing opened pages and resources) and H5 caching (AppCache).
By default this is set to true and the WebView accepts cookies.
Please add below code
mWebView.getSettings().setAppCacheEnabled(false); mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
Please remove app from history task and test its working.
Just after creating your webview, before loading any pages, you can clear the cache.
myBrowser.clearCache(true)
- the boolean indicates if you wish to delete the cached files on disk as well.
The documentation is here if you wish to dig further.
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