| 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.|
| 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 the **Preferences** instance obtained is returned. Otherwise, **err** is an error code.|
**Example**
...
...
@@ -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
| 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
| 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.|
...
...
@@ -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. |
...
...
@@ -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. |
**Example**
```js
preferences.put('startup','auto',function(err){
if(err){
...
...
@@ -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. |
| 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. |
| 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**
```js
preferences.has('startup',function(err,isExist){
if(err){
...
...
@@ -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.|
...
...
@@ -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. |
| 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**
```js
preferences.delete('startup',function(err){
if(err){
...
...
@@ -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.|
**Example**
```js
preferences.clear(function(err){
if(err){
...
...
@@ -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.|