WebStorageCompat
public final 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 methods |
|
|---|---|
static void |
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Delete all data stored by websites in the given WebStorage instance. |
static void |
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Delete all data stored by websites in the given WebStorage instance. |
static @NonNull String |
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Delete data stored by web storage APIs for the specified domain in the given WebStorage instance. |
static @NonNull String |
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")Delete data stored by web storage APIs for the specified domain in the given WebStorage instance. |
Public methods
deleteBrowsingData
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
public static void deleteBrowsingData(
@NonNull WebStorage instance,
@NonNull Runnable doneCallback
)
Delete all data stored by websites in the given WebStorage instance.
This method functions as deleteBrowsingData, but invokes the doneCallback on the UI thread.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
| See also | |
|---|---|
deleteBrowsingData |
deleteBrowsingData
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
public static void deleteBrowsingData(
@NonNull WebStorage instance,
@NonNull Executor executor,
@NonNull Runnable doneCallback
)
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 | |
|---|---|
@NonNull WebStorage instance |
WebStorage instance to delete all data in. |
@NonNull Executor executor |
Executor to run the |
@NonNull Runnable doneCallback |
callback that will be invoked when deletion is complete. |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
deleteBrowsingDataForSite
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
public static @NonNull String deleteBrowsingDataForSite(
@NonNull WebStorage instance,
@NonNull String site,
@NonNull Runnable doneCallback
)
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.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the |
| See also | |
|---|---|
deleteBrowsingDataForSite |
deleteBrowsingDataForSite
@RequiresFeature(name = WebViewFeature.DELETE_BROWSING_DATA, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@UiThread
public static @NonNull String deleteBrowsingDataForSite(
@NonNull WebStorage instance,
@NonNull String site,
@NonNull Executor executor,
@NonNull Runnable doneCallback
)
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 | |
|---|---|
@NonNull WebStorage instance |
WebStorage instance to delete all data in. |
@NonNull String site |
The site to delete for. This can be a domain name, or a full URL. |
@NonNull Executor executor |
Executor to run the |
@NonNull Runnable doneCallback |
callback that will be invoked when deletion is complete. |
| Returns | |
|---|---|
@NonNull String |
The domain that was used for deletion. This will be the top-level domain part of the |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if unable to parse the |
java.lang.UnsupportedOperationException |
if the |