Webview settings

Issue

I just want to check let’s say if I do this in my app (For the web view) Will it affect other application’s too? I mean if I set the web view settings will it affected as global web view setting?

webSettings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
    webSettings.setAllowFileAccessFromFileURLs(true);
    webSettings.setAllowUniversalAccessFromFileURLs(true);
}

Solution

According to the official doc for WebSettings:

Manages settings state for a WebView. When a WebView is first created, it obtains a set of default settings. These default settings will be returned from any getter call. A WebSettings object obtained from WebView.getSettings() is tied to the life of the WebView. If a WebView has been destroyed, any method call on WebSettings will throw an IllegalStateException.

So in short: No, it won’t affect global settings for WebView (as there are no global settings).

Answered By – Thomas S.E.

Leave a Comment