Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset webview to its initial state

How am i supposed to reset a WebView state (cache, cookies, and everything else)?

What I want is that the webview state, preferences, etc. is completely reset to the default (when we first ran the app, or after we have cleared the app data from settings).

like image 536
Manza Avatar asked Sep 12 '25 12:09

Manza


1 Answers

Initialize the WebView with the following settings:

Don't use the cache, load from the network.

mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

Sets whether the WebView should save form data.

mWebView.getSettings().setSaveFormData(boolean save) 

Then when you want to wipe out, do:

mWebView.clearCache(true);

This clears the resource cache including the disk files.

like image 137
Gayan Weerakutti Avatar answered Sep 14 '25 03:09

Gayan Weerakutti