WebStorageCompat


class WebStorageCompat


Compatibility class for android.webkit.WebStorage that introduces new methods to completely clear data.

WebStorage is tied to WebView Profile instances. If your app uses multiple profiles, then you should ensure that you clear data for all relevant profiles.

A android.webkit.WebStorage instance can be obtained from getInstance, or from getWebStorage if your app is using multiple WebView profiles.

Summary

Public functions

java-static Unit
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
deleteBrowsingData(instance: WebStorage, doneCallback: Runnable)

Delete all data stored by websites in the given WebStorage instance.

java-static Unit
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
deleteBrowsingData(
    instance: WebStorage,
    executor: Executor,
    doneCallback: Runnable
)

Delete all data stored by websites in the given WebStorage instance.

java-static String
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
deleteBrowsingDataForSite(
    instance: WebStorage,
    site: String,
    doneCallback: Runnable
)

Delete data stored by web storage APIs for the specified domain in the given WebStorage instance.

java-static String
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
deleteBrowsingDataForSite(
    instance: WebStorage,
    site: String,
    executor: Executor,
    doneCallback: Runnable
)

Delete data stored by web storage APIs for the specified domain in the given WebStorage instance.

Public functions

deleteBrowsingData

@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun deleteBrowsingData(instance: WebStorage, doneCallback: Runnable): Unit

Delete all data stored by websites in the given WebStorage instance.

This method functions as deleteBrowsingData, but invokes the doneCallback on the UI thread.

deleteBrowsingData

@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun deleteBrowsingData(
    instance: WebStorage,
    executor: Executor,
    doneCallback: Runnable
): Unit

Delete all data stored by websites in the given WebStorage instance. This includes network cache, cookies, and any JavaScript-readable storage.

This method will delete all data that was stored before being invoked. Deletion is not an atomic operation, so it may also delete data that is stored during deletion, but this is not guaranteed.

Parameters
instance: WebStorage

WebStorage instance to delete all data in.

executor: Executor

Executor to run the doneCallback.

doneCallback: Runnable

callback that will be invoked when deletion is complete.

deleteBrowsingDataForSite

@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun deleteBrowsingDataForSite(
    instance: WebStorage,
    site: String,
    doneCallback: Runnable
): String

Delete data stored by web storage APIs for the specified domain in the given WebStorage instance.

This method functions as deleteBrowsingDataForSite, but invokes the doneCallback on the UI thread.

deleteBrowsingDataForSite

@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
java-static fun deleteBrowsingDataForSite(
    instance: WebStorage,
    site: String,
    executor: Executor,
    doneCallback: Runnable
): String

Delete data stored by web storage APIs for the specified domain in the given WebStorage instance. This includes network cache, cookies, and any JavaScript-readable storage.

For partitioned storage, this method will remove all data owned by the site, as well as all storage for content embedded in the specified site, e.g. iframed content.

This method deletes storage for the site part of the input argument. This means that if the input argument contains a subdomain (for example www.example.com), then this method will delete everything belonging to example.com.

This method will delete all data that was stored before being invoked. Deletion is not an atomic operation, so it may also delete data that is stored during deletion, but this is not guaranteed.

Parameters
instance: WebStorage

WebStorage instance to delete all data in.

site: String

The site to delete for. This can be a domain name, or a full URL.

executor: Executor

Executor to run the doneCallback.

doneCallback: Runnable

callback that will be invoked when deletion is complete.

Returns
String

The domain that was used for deletion. This will be the top-level domain part of the domain parameter.

Throws
java.lang.IllegalArgumentException

if unable to parse the domain as a domain name.