Most visited

Recently visited

Added in API level 5

WebStorage

public class WebStorage
extends Object

java.lang.Object
   ↳ android.webkit.WebStorage


This class is used to manage the JavaScript storage APIs provided by the WebView. It manages the Application Cache API, the Web SQL Database API and the HTML5 Web Storage API. The Application Cache API provides a mechanism to create and maintain an application cache to power offline Web applications. Use of the Application Cache API can be attributed to an origin WebStorage.Origin, however it is not possible to set per-origin quotas. Note that there can be only one application cache per application. The Web SQL Database API provides storage which is private to a given origin. Similar to the Application Cache, use of the Web SQL Database can be attributed to an origin. It is also possible to set per-origin quotas.

Summary

Nested classes

class WebStorage.Origin

This class encapsulates information about the amount of storage currently used by an origin for the JavaScript storage APIs. 

interface WebStorage.QuotaUpdater

This interface was deprecated in API level 19. This class is obsolete and no longer used.  

Public methods

void deleteAllData()

Clears all storage currently being used by the JavaScript storage APIs.

void deleteOrigin(String origin)

Clears the storage currently being used by both the Application Cache and Web SQL Database APIs by the given origin.

static WebStorage getInstance()

Gets the singleton instance of this class.

void getOrigins(ValueCallback<Map> callback)

Gets the origins currently using either the Application Cache or Web SQL Database APIs.

void getQuotaForOrigin(String origin, ValueCallback<Long> callback)

Gets the storage quota for the Web SQL Database API for the given origin.

void getUsageForOrigin(String origin, ValueCallback<Long> callback)

Gets the amount of storage currently being used by both the Application Cache and Web SQL Database APIs by the given origin.

void setQuotaForOrigin(String origin, long quota)

This method was deprecated in API level 18. Controlling quota per-origin will not be supported in future.

Inherited methods

From class java.lang.Object

Public methods

deleteAllData

Added in API level 7
void deleteAllData ()

Clears all storage currently being used by the JavaScript storage APIs. This includes the Application Cache, Web SQL Database and the HTML5 Web Storage APIs.

deleteOrigin

Added in API level 7
void deleteOrigin (String origin)

Clears the storage currently being used by both the Application Cache and Web SQL Database APIs by the given origin. The origin is specified using its string representation.

Parameters
origin String

getInstance

Added in API level 7
WebStorage getInstance ()

Gets the singleton instance of this class.

Returns
WebStorage the singleton WebStorage instance

getOrigins

Added in API level 7
void getOrigins (ValueCallback<Map> callback)

Gets the origins currently using either the Application Cache or Web SQL Database APIs. This method operates asynchronously, with the result being provided via a ValueCallback. The origins are provided as a map, of type Map<String, WebStorage.Origin>, from the string representation of the origin to a WebStorage.Origin object.

Parameters
callback ValueCallback

getQuotaForOrigin

Added in API level 7
void getQuotaForOrigin (String origin, 
                ValueCallback<Long> callback)

Gets the storage quota for the Web SQL Database API for the given origin. The quota is given in bytes and the origin is specified using its string representation. This method operates asynchronously, with the result being provided via a ValueCallback. Note that a quota is not enforced on a per-origin basis for the Application Cache API.

Parameters
origin String
callback ValueCallback

getUsageForOrigin

Added in API level 7
void getUsageForOrigin (String origin, 
                ValueCallback<Long> callback)

Gets the amount of storage currently being used by both the Application Cache and Web SQL Database APIs by the given origin. The amount is given in bytes and the origin is specified using its string representation. This method operates asynchronously, with the result being provided via a ValueCallback.

Parameters
origin String
callback ValueCallback

setQuotaForOrigin

Added in API level 7
void setQuotaForOrigin (String origin, 
                long quota)

This method was deprecated in API level 18.
Controlling quota per-origin will not be supported in future.

Sets the storage quota for the Web SQL Database API for the given origin. The quota is specified in bytes and the origin is specified using its string representation. Note that a quota is not enforced on a per-origin basis for the Application Cache API.

Parameters
origin String
quota long

Hooray!