WebViewDatabase  |  API reference  |  Android Developers


public abstract class WebViewDatabase
extends Object



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 getInstance(Context) instead to fetch the singleton instance.

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 WebViewDatabase instance.

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 WebViewDatabase instance.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

WebViewDatabase

public WebViewDatabase ()

This constructor is deprecated.
This class should not be constructed by applications, use getInstance(Context) instead to fetch the singleton instance.

Public methods

clearFormData

public abstract void clearFormData ()

Clears any saved data for web forms.

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.

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

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.
  • WebView does not provide a special mechanism to clear HTTP authentication credentials 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).
  • 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