提交 12fd8e71 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 a4fbbf90
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type.
> **NOTE**<br/> > **NOTE**
> >
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>
## Modules to Import ## Modules to Import
...@@ -33,20 +35,20 @@ Reads the specified file and loads its data to the **Storage** instance for data ...@@ -33,20 +35,20 @@ Reads the specified file and loads its data to the **Storage** instance for data
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [Storage](#storage) | **Storage** instance used for data storage operations.| | [Storage](#storage) | **Storage** instance used for data storage operations.|
**Example** **Example**
```js ```js
import data_storage from '@ohos.data.storage' import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage' let path = '/data/storage/el2/database'
let storage = data_storage.getStorageSync(path + '/mystore') let storage = data_storage.getStorageSync(path + '/mystore')
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
storage.flushSync() storage.flushSync()
...@@ -63,19 +65,19 @@ Reads the specified file and loads its data to the **Storage** instance for data ...@@ -63,19 +65,19 @@ Reads the specified file and loads its data to the **Storage** instance for data
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
| callback | AsyncCallback&lt;[Storage](#storage)&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;[Storage](#storage)&gt; | Yes| Callback used to return the execution result.|
**Example** **Example**
```js ```js
import data_storage from '@ohos.data.storage' import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage' let path = '/data/storage/el2/database'
data_storage.getStorage(path + '/mystore', function (err, storage) { data_storage.getStorage(path + '/mystore', function (err, storage) {
if (err) { if (err) {
console.info("Get the storage failed, path: " + path + '/mystore') console.info("Failed to get the storage. Path: " + path + '/mystore')
return; return;
} }
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
...@@ -93,27 +95,27 @@ Reads the specified file and loads its data to the **Storage** instance for data ...@@ -93,27 +95,27 @@ Reads the specified file and loads its data to the **Storage** instance for data
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[Storage](#storage)&gt; | Promise used to return the result.| | Promise&lt;[Storage](#storage)&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
import data_storage from '@ohos.data.storage' import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage' let path = '/data/storage/el2/database'
let getPromise = data_storage.getStorage(path + '/mystore') let getPromise = data_storage.getStorage(path + '/mystore')
getPromise.then((storage) => { getPromise.then((storage) => {
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
storage.flushSync() storage.flushSync()
}).catch((err) => { }).catch((err) => {
console.info("Get the storage failed, path: " + path + '/mystore') console.info("Failed to get the storage. Path: " + path + '/mystore')
}) })
``` ```
...@@ -127,12 +129,13 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -127,12 +129,13 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
data_storage.deleteStorageSync(path + '/mystore') data_storage.deleteStorageSync(path + '/mystore')
``` ```
...@@ -146,13 +149,14 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -146,13 +149,14 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
data_storage.deleteStorage(path + '/mystore', function (err) { data_storage.deleteStorage(path + '/mystore', function (err) {
if (err) { if (err) {
console.info("Deleted failed with err: " + err) console.info("Deleted failed with err: " + err)
...@@ -172,17 +176,18 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -172,17 +176,18 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
let promisedelSt = data_storage.deleteStorage(path + '/mystore') let promisedelSt = data_storage.deleteStorage(path + '/mystore')
promisedelSt.then(() => { promisedelSt.then(() => {
console.info("Deleted successfully.") console.info("Deleted successfully.")
...@@ -201,12 +206,13 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ...@@ -201,12 +206,13 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
data_storage.removeStorageFromCacheSync(path + '/mystore') data_storage.removeStorageFromCacheSync(path + '/mystore')
``` ```
...@@ -220,13 +226,14 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ...@@ -220,13 +226,14 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
data_storage.removeStorageFromCache(path + '/mystore', function (err) { data_storage.removeStorageFromCache(path + '/mystore', function (err) {
if (err) { if (err) {
console.info("Removed storage from cache failed with err: " + err) console.info("Removed storage from cache failed with err: " + err)
...@@ -246,17 +253,18 @@ Removes the singleton **Storage** instance of a file from the cache. The removed ...@@ -246,17 +253,18 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | Yes| Path of the target file.| | path | string | Yes| Path of the target file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let path = '/data/storage/el2/database'
let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore') let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore')
promiserevSt.then(() => { promiserevSt.then(() => {
console.info("Removed storage from cache successfully.") console.info("Removed storage from cache successfully.")
...@@ -280,15 +288,15 @@ Obtains the value corresponding to a key. If the value is null or not in the def ...@@ -280,15 +288,15 @@ Obtains the value corresponding to a key. If the value is null or not in the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned if the value of the specified key does not exist. It can be a number, string, or Boolean value.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned.| | ValueType | Value corresponding to the specified key. If the value is null or not in the default value format, the default value is returned.|
**Example** **Example**
```js ```js
...@@ -306,11 +314,11 @@ Obtains the value corresponding to a key. If the value is null or not in the def ...@@ -306,11 +314,11 @@ Obtains the value corresponding to a key. If the value is null or not in the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
| callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the execution result.|
**Example** **Example**
```js ```js
...@@ -340,9 +348,9 @@ Obtains the value corresponding to a key. If the value is null or not in the def ...@@ -340,9 +348,9 @@ Obtains the value corresponding to a key. If the value is null or not in the def
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;ValueType&gt; | Promise used to return the result.| | Promise&lt;ValueType&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
...@@ -364,10 +372,10 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat ...@@ -364,10 +372,10 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| 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| New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
**Example** **Example**
```js ```js
...@@ -384,11 +392,11 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat ...@@ -384,11 +392,11 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| 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| New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
...@@ -411,15 +419,15 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat ...@@ -411,15 +419,15 @@ Obtains the **Storage** instance corresponding to the specified file, writes dat
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| 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| New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
...@@ -441,14 +449,14 @@ Checks whether the storage object contains data with a given key. ...@@ -441,14 +449,14 @@ Checks whether the storage object contains data with a given key.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| | boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -468,15 +476,15 @@ Checks whether the storage object contains data with a given key. This API uses ...@@ -468,15 +476,15 @@ Checks whether the storage object contains data with a given key. This API uses
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the execution result.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.| | boolean | Returns **true** if the storage object contains data with the specified key; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -501,14 +509,14 @@ Checks whether the storage object contains data with a given key. This API uses ...@@ -501,14 +509,14 @@ Checks whether the storage object contains data with a given key. This API uses
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
...@@ -532,9 +540,9 @@ Deletes data with the specified key from this storage object. ...@@ -532,9 +540,9 @@ Deletes data with the specified key from this storage object.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
**Example** **Example**
```js ```js
...@@ -551,10 +559,10 @@ Deletes data with the specified key from this storage object. This API uses an a ...@@ -551,10 +559,10 @@ Deletes data with the specified key from this storage object. This API uses an a
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
...@@ -577,14 +585,14 @@ Deletes data with the specified key from this storage object. This API uses a pr ...@@ -577,14 +585,14 @@ Deletes data with the specified key from this storage object. This API uses a pr
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data.| | key | string | Yes| Key of the data.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
...@@ -620,9 +628,9 @@ Saves the modification of this object to the **Storage** instance and synchroniz ...@@ -620,9 +628,9 @@ Saves the modification of this object to the **Storage** instance and synchroniz
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
...@@ -645,9 +653,9 @@ Saves the modification of this object to the **Storage** instance and synchroniz ...@@ -645,9 +653,9 @@ Saves the modification of this object to the **Storage** instance and synchroniz
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
...@@ -683,9 +691,9 @@ Clears this **Storage** object. This API uses an asynchronous callback to return ...@@ -683,9 +691,9 @@ Clears this **Storage** object. This API uses an asynchronous callback to return
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example** **Example**
```js ```js
...@@ -708,9 +716,9 @@ Clears this **Storage** object. This API uses a promise to return the result. ...@@ -708,9 +716,9 @@ Clears this **Storage** object. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
...@@ -732,10 +740,10 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe ...@@ -732,10 +740,10 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string | Event type. The value **change** indicates data change events.|
| callback | Callback&lt;[StorageObserver](#storageobserver)&gt; | Callback used to return data changes.| | callback | Callback&lt;[StorageObserver](#storageobserver)&gt; | Callback used to return data changes.|
**Example** **Example**
```js ```js
...@@ -757,10 +765,10 @@ Unsubscribes from data changes. ...@@ -757,10 +765,10 @@ Unsubscribes from data changes.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string | Event type. The value **change** indicates data change events.|
| callback | Callback&lt;[StorageObserver](#storageobserver)&gt; | Callback used to return data changes.| | callback | Callback&lt;[StorageObserver](#storageobserver)&gt; | Callback used to return data changes.|
**Example** **Example**
```js ```js
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册