Stay organized with collections
Save and categorize content based on your preferences.
WebStorage
open class WebStorage
This class is used to manage the JavaScript storage APIs provided by the WebView
. It manages the Web SQL Database API and the HTML5 Web Storage API. The Web SQL Database API provides storage which is private to a given origin. Use of the Web SQL Database can be attributed to an origin. It is also possible to set per-origin quotas.
Summary
Nested classes |
open |
This class encapsulates information about the amount of storage currently used by an origin for the JavaScript storage APIs.
|
abstract |
Encapsulates a callback function which is used to provide a new quota for a JavaScript storage API.
|
Public methods |
open Unit |
Clears all storage currently being used by the JavaScript storage APIs.
|
open Unit |
Clears the storage currently being used by the Web SQL Database APIs by the given origin.
|
open static WebStorage! |
Gets the singleton instance of this class.
|
open Unit |
Gets the origins currently using the Web SQL Database APIs.
|
open Unit |
Gets the storage quota for the Web SQL Database API for the given origin.
|
open Unit |
Gets the amount of storage currently being used by the Web SQL Database APIs by the given origin.
|
open Unit |
Sets the storage quota for the Web SQL Database API for the given origin.
|
Public methods
deleteAllData
open fun deleteAllData(): Unit
Clears all storage currently being used by the JavaScript storage APIs. This includes Web SQL Database and the HTML5 Web Storage APIs.
deleteOrigin
open fun deleteOrigin(origin: String!): Unit
Clears the storage currently being used by the Web SQL Database APIs by the given origin. The origin is specified using its string representation.
getInstance
open static fun getInstance(): WebStorage!
Gets the singleton instance of this class.
getOrigins
open fun getOrigins(callback: ValueCallback<MutableMap<Any?, Any?>!>!): Unit
Gets the origins currently using the 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.
getQuotaForOrigin
open fun getQuotaForOrigin(
origin: String!,
callback: ValueCallback<Long!>!
): Unit
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
.
getUsageForOrigin
open fun getUsageForOrigin(
origin: String!,
callback: ValueCallback<Long!>!
): Unit
Gets the amount of storage currently being used by the 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
.
setQuotaForOrigin
open fun setQuotaForOrigin(
origin: String!,
quota: Long
): Unit
Deprecated: 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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# WebStorage\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nWebStorage\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/webkit/WebStorage \"View this page in Java\") \n\n```\nopen class WebStorage\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.webkit.WebStorage](#) |\n\nThis class is used to manage the JavaScript storage APIs provided by the [WebView](/reference/kotlin/android/webkit/WebView). It manages the Web SQL Database API and the HTML5 Web Storage API. The Web SQL Database API provides storage which is private to a given origin. Use of the Web SQL Database can be attributed to an origin. It is also possible to set per-origin quotas.\n\nSummary\n-------\n\n| Nested classes ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open | [Origin](/reference/kotlin/android/webkit/WebStorage.Origin) This class encapsulates information about the amount of storage currently used by an origin for the JavaScript storage APIs. |\n| abstract | [QuotaUpdater](/reference/kotlin/android/webkit/WebStorage.QuotaUpdater) Encapsulates a callback function which is used to provide a new quota for a JavaScript storage API. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [deleteAllData](#deleteAllData())`()` Clears all storage currently being used by the JavaScript storage APIs. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [deleteOrigin](#deleteOrigin(kotlin.String))`(`origin:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Clears the storage currently being used by the Web SQL Database APIs by the given origin. |\n| open static [WebStorage](#)! | [getInstance](#getInstance())`()` Gets the singleton instance of this class. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [getOrigins](#getOrigins(android.webkit.ValueCallback))`(`callback:` `[ValueCallback](/reference/kotlin/android/webkit/ValueCallback)\u003c[MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\u003c[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?,` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?\u003e!\u003e!`)` Gets the origins currently using the Web SQL Database APIs. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [getQuotaForOrigin](#getQuotaForOrigin(kotlin.String,%20android.webkit.ValueCallback))`(`origin:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `callback:` `[ValueCallback](/reference/kotlin/android/webkit/ValueCallback)\u003c[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)!\u003e!`)` Gets the storage quota for the Web SQL Database API for the given origin. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [getUsageForOrigin](#getUsageForOrigin(kotlin.String,%20android.webkit.ValueCallback))`(`origin:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `callback:` `[ValueCallback](/reference/kotlin/android/webkit/ValueCallback)\u003c[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)!\u003e!`)` Gets the amount of storage currently being used by the Web SQL Database APIs by the given origin. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [setQuotaForOrigin](#setQuotaForOrigin(kotlin.String,%20kotlin.Long))`(`origin:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `quota:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets the storage quota for the Web SQL Database API for the given origin. |\n\nPublic methods\n--------------\n\n### deleteAllData\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun deleteAllData(): Unit\n```\n\nClears all storage currently being used by the JavaScript storage APIs. This includes Web SQL Database and the HTML5 Web Storage APIs. \n\n### deleteOrigin\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun deleteOrigin(origin: String!): Unit\n```\n\nClears the storage currently being used by the Web SQL Database APIs by the given origin. The origin is specified using its string representation. \n\n### getInstance\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getInstance(): WebStorage!\n```\n\nGets the singleton instance of this class.\n\n| Return ||\n|------------------|----------------------------------------|\n| [WebStorage](#)! | the singleton [WebStorage](#) instance |\n\n### getOrigins\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getOrigins(callback: ValueCallback\u003cMutableMap\u003cAny?, Any?\u003e!\u003e!): Unit\n```\n\nGets the origins currently using the Web SQL Database APIs. This method operates asynchronously, with the result being provided via a [ValueCallback](/reference/kotlin/android/webkit/ValueCallback). The origins are provided as a map, of type `Map\u003cString, WebStorage.Origin\u003e`, from the string representation of the origin to a [WebStorage.Origin](/reference/kotlin/android/webkit/WebStorage.Origin) object. \n\n### getQuotaForOrigin\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getQuotaForOrigin(\n origin: String!, \n callback: ValueCallback\u003cLong!\u003e!\n): Unit\n```\n\nGets 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](/reference/kotlin/android/webkit/ValueCallback). \n\n### getUsageForOrigin\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getUsageForOrigin(\n origin: String!, \n callback: ValueCallback\u003cLong!\u003e!\n): Unit\n```\n\nGets the amount of storage currently being used by the 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](/reference/kotlin/android/webkit/ValueCallback). \n\n### setQuotaForOrigin\n\nAdded in [API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setQuotaForOrigin(\n origin: String!, \n quota: Long\n): Unit\n```\n\n**Deprecated:** *Controlling quota per-origin will not be supported in future.*\n\nSets 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."]]