FileDocCategorySizeDatePackage
WebStorage.javaAPI DocAndroid 5.1 API8254Thu Mar 12 22:22:10 GMT 2015android.webkit

WebStorage

public class WebStorage extends Object
This class is used to manage the JavaScript storage APIs provided by the {@link 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 {@link 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.

Fields Summary
Constructors Summary
public WebStorage()
This class should not be instantiated directly, applications must only use {@link #getInstance()} to obtain the instance. Note this constructor was erroneously public and published in SDK levels prior to 16, but applications using it would receive a non-functional instance of this class (there was no way to call createHandler() and createUIHandler(), so it would not work).

hide

Methods Summary
public voiddeleteAllData()
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.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.
    
public voiddeleteOrigin(java.lang.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.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.
    
public static android.webkit.WebStoragegetInstance()
Gets the singleton instance of this class.

return
the singleton {@link WebStorage} instance

      return WebViewFactory.getProvider().getWebStorage();
    
public voidgetOrigins(ValueCallback 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 {@link ValueCallback}. The origins are provided as a map, of type {@code Map}, from the string representation of the origin to a {@link WebStorage.Origin} object.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.
    
public voidgetQuotaForOrigin(java.lang.String origin, ValueCallback 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 {@link ValueCallback}. Note that a quota is not enforced on a per-origin basis for the Application Cache API.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.
    
public voidgetUsageForOrigin(java.lang.String origin, ValueCallback 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 {@link ValueCallback}.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.
    
public voidsetQuotaForOrigin(java.lang.String origin, long quota)
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.

deprecated
Controlling quota per-origin will not be supported in future.

        // Must be a no-op for backward compatibility: see the hidden constructor for reason.