WebViewDatabase
public abstract class WebViewDatabase
extends Object
java.lang.Object | |
↳ | android.webkit.WebViewDatabase |
This class allows developers to determine whether any WebView used in the application has stored any of the following types of browsing data and to clear any such stored data for all WebViews in the application.
- Username/password pairs for web forms
- HTTP authentication username/password pairs
- Data entered into text fields (e.g. for autocomplete suggestions)
Summary
Public constructors | |
---|---|
WebViewDatabase() This constructor is deprecated. This class should not be constructed by applications, use |
Public methods | |
---|---|
abstract void | clearFormData() Clears any saved data for web forms. |
abstract void | clearHttpAuthUsernamePassword() Clears any saved credentials for HTTP authentication. |
abstract void | clearUsernamePassword() This method was deprecated in API level 18. Saving passwords in WebView will not be supported in future versions. |
abstract String[] | getHttpAuthUsernamePassword(String host, String realm) Retrieves HTTP authentication credentials for a given host and realm from the |
static WebViewDatabase | getInstance(Context context) |
abstract boolean | hasFormData() Gets whether there is any saved data for web forms. |
abstract boolean | hasHttpAuthUsernamePassword() Gets whether there are any saved credentials for HTTP authentication. |
abstract boolean | hasUsernamePassword() This method was deprecated in API level 18. Saving passwords in WebView will not be supported in future versions. |
abstract void | setHttpAuthUsernamePassword(String host, String realm, String username, String password) Stores HTTP authentication credentials for a given host and realm to the |
Inherited methods | |
---|---|
Public constructors
WebViewDatabase
public WebViewDatabase ()
This constructor is deprecated.
This class should not be constructed by applications, use getInstance(android.content.Context)
instead to fetch the singleton instance.
Public methods
clearFormData
public abstract void clearFormData ()
Clears any saved data for web forms.
See also:
clearHttpAuthUsernamePassword
public abstract void clearHttpAuthUsernamePassword ()
Clears any saved credentials for HTTP authentication. This method only clears the username and password stored in WebViewDatabase instance. The username and password are not read from the WebViewDatabase
during WebViewClient.onReceivedHttpAuthRequest
. It is up to the app to do this or not.
The username and password used for http authentication might be cached in the network stack itself, and are not cleared when this method is called. WebView does not provide a special mechanism to clear HTTP authentication for implementing client logout. The client logout mechanism should be implemented by the Web site designer (such as server sending a HTTP 401 for invalidating credentials).
clearUsernamePassword
public abstract void clearUsernamePassword ()
This method was deprecated in API level 18.
Saving passwords in WebView will not be supported in future versions.
Clears any saved username/password pairs for web forms. Note that these are unrelated to HTTP authentication credentials.
getHttpAuthUsernamePassword
public abstract String[] getHttpAuthUsernamePassword (String host, String realm)
Retrieves HTTP authentication credentials for a given host and realm from the WebViewDatabase
instance.
Parameters | |
---|---|
host | String : the host to which the credentials apply |
realm | String : the realm to which the credentials apply |
Returns | |
---|---|
String[] | the credentials as a String array, if found. The first element is the username and the second element is the password. null if no credentials are found. |
getInstance
public static WebViewDatabase getInstance (Context context)
Parameters | |
---|---|
context | Context |
Returns | |
---|---|
WebViewDatabase |
hasFormData
public abstract boolean hasFormData ()
Gets whether there is any saved data for web forms.
Returns | |
---|---|
boolean | whether there is any saved data for web forms |
See also:
hasHttpAuthUsernamePassword
public abstract boolean hasHttpAuthUsernamePassword ()
Gets whether there are any saved credentials for HTTP authentication.
Returns | |
---|---|
boolean | whether there are any saved credentials |
hasUsernamePassword
public abstract boolean hasUsernamePassword ()
This method was deprecated in API level 18.
Saving passwords in WebView will not be supported in future versions.
Gets whether there are any saved username/password pairs for web forms. Note that these are unrelated to HTTP authentication credentials.
Returns | |
---|---|
boolean | true if there are any saved username/password pairs |
setHttpAuthUsernamePassword
public abstract void setHttpAuthUsernamePassword (String host, String realm, String username, String password)
Stores HTTP authentication credentials for a given host and realm to the WebViewDatabase
instance.
To use HTTP authentication, the embedder application has to implement WebViewClient.onReceivedHttpAuthRequest
, and call HttpAuthHandler.proceed
with the correct username and password.
The embedder app can get the username and password any way it chooses, and does not have to use WebViewDatabase
.
Notes:
WebViewDatabase
is provided only as a convenience to store and retrieve http authentication credentials. WebView does not read from it during HTTP authentication. Parameters | |
---|---|
host | String : the host to which the credentials apply |
realm | String : the realm to which the credentials apply |
username | String : the username |
password | String : the password |