| name | string | Yes | Name of the **Preferences** instance. |
| name | string | Yes | Name of the **Preferences** instance. |
| callback | AsyncCallback<[Preferences](#preferences)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **object** is the **Preferences** instance obtained. Otherwise, **err** is an error code.|
| callback | AsyncCallback<[Preferences](#preferences)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is undefined and the **Preferences** instance obtained is returned. Otherwise, **err** is an error code.|
**Example**
**Example**
...
@@ -66,12 +66,14 @@ Obtains a **Preferences** instance. This API uses a promise to return the result
...
@@ -66,12 +66,14 @@ Obtains a **Preferences** instance. This API uses a promise to return the result
@@ -110,6 +113,7 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi
...
@@ -110,6 +113,7 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
@@ -173,6 +181,7 @@ The removed **Preferences** instance cannot be used for data operations. Otherwi
...
@@ -173,6 +181,7 @@ The removed **Preferences** instance cannot be used for data operations. Otherwi
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<Object> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **value** is the **Object** instance obtained. Otherwise, **err** is an error code.|
| callback | AsyncCallback<Object> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **value** is the **Object** instance obtained. Otherwise, **err** is an error code.|
...
@@ -318,11 +334,13 @@ Obtains an **Object** instance that contains all KV pairs. This API uses a promi
...
@@ -318,11 +334,13 @@ Obtains an **Object** instance that contains all KV pairs. This API uses a promi
| key | string | Yes | Key of the data. It cannot be empty. |
| key | string | Yes | Key of the data. It cannot be empty. |
...
@@ -350,6 +369,7 @@ Writes data to this **Preferences** instance. This API uses an asynchronous call
...
@@ -350,6 +369,7 @@ Writes data to this **Preferences** instance. This API uses an asynchronous call
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is undefined. Otherwise, **err** is an error code. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is undefined. Otherwise, **err** is an error code. |
**Example**
**Example**
```js
```js
preferences.put('startup','auto',function(err){
preferences.put('startup','auto',function(err){
if(err){
if(err){
...
@@ -370,17 +390,20 @@ Writes data to this **Preferences** instance. This API uses a promise to return
...
@@ -370,17 +390,20 @@ Writes data to this **Preferences** instance. This API uses a promise to return
| key | string | Yes | Key of the data. It cannot be empty. |
| key | string | Yes | Key of the data. It cannot be empty. |
| value | [ValueType](#valuetype) | Yes | Value to write. The value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.|
| value | [ValueType](#valuetype) | Yes | Value to write. The value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.|
| key | string | Yes | Key of the data to check. It cannot be empty. |
| key | string | Yes | Key of the data to check. It cannot be empty. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If the **Preferences** instance contains the KV pair, **true** will be returned. Otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If the **Preferences** instance contains the KV pair, **true** will be returned. Otherwise, **false** will be returned.|
**Example**
**Example**
```js
```js
preferences.has('startup',function(err,isExist){
preferences.has('startup',function(err,isExist){
if(err){
if(err){
...
@@ -430,11 +455,13 @@ Checks whether this **Preferences** instance contains data with the given key. T
...
@@ -430,11 +455,13 @@ Checks whether this **Preferences** instance contains data with the given key. T
| Promise<boolean> | Promise used to return the result. If the **Preferences** instance contains the KV pair, **true** will be returned. Otherwise, **false** will be returned.|
| Promise<boolean> | Promise used to return the result. If the **Preferences** instance contains the KV pair, **true** will be returned. Otherwise, **false** will be returned.|
...
@@ -464,12 +491,14 @@ Deletes a KV pair from this **Preferences** instance. This API uses an asynchron
...
@@ -464,12 +491,14 @@ Deletes a KV pair from this **Preferences** instance. This API uses an asynchron
| key | string | Yes | Key of the KV pair to delete. It cannot be empty. |
| key | string | Yes | Key of the KV pair to delete. It cannot be empty. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
**Example**
**Example**
```js
```js
preferences.delete('startup',function(err){
preferences.delete('startup',function(err){
if(err){
if(err){
...
@@ -490,16 +519,19 @@ Deletes a KV pair from this **Preferences** instance. This API uses a promise to
...
@@ -490,16 +519,19 @@ Deletes a KV pair from this **Preferences** instance. This API uses a promise to
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.|
**Example**
**Example**
```js
```js
preferences.clear(function(err){
preferences.clear(function(err){
if(err){
if(err){
...
@@ -593,11 +631,13 @@ Clears this **Preferences** instance. This API uses a promise to return the resu
...
@@ -593,11 +631,13 @@ Clears this **Preferences** instance. This API uses a promise to return the resu
| type | string | Yes | Event type to unsubscribe from. The value **change** indicates data change events. |
| callback | Callback<{ key : string }> | No | Callback to unregister. If this parameter is left blank, the callbacks used to subscribing to all data changes will be unregistered.|