androidwebviewandroid-websettings

do webview settings affect all webview?


Having WebView, and some settings. The question is will these settings set on one WebView instance affect the browser of the other WebView instance, such as the browser cache, domStorage?

mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setAppCacheEnabled(false);
mWebView.getSettings().setDomStorageEnabled(true);

What if set the settings on a webView in one activity and called activity.finish(), later in other activity instantiates new webView.

If they do get carried over, how to clear the data stored by the setting of setDomStorageEnabled(true)?


Solution

  • The question is will these settings set on one WebView instance affect the browser of the other WebView instance

    No. If you change the settings for one WebView the settings for other WebViews will stay the same. Ie. If you change the settings for myWebView, then SomeOtherWebview will still have the original settings.

    activity.finish(), later in other activity instantiates new webView

    Your new WebView will be a fresh one, with the default settings.


    Note that all WebViews in your app share:

    Check this for how to clear everything.