提交 1e3a2681 编写于 作者: P PaDaBoo

ohos Handling API interface integrity and consistency

Signed-off-by: NPaDaBoo <xuejianwu@huawei.com>
上级 da71d188
...@@ -15,10 +15,12 @@ import data_Preferences from '@ohos.data.preferences' ...@@ -15,10 +15,12 @@ import data_Preferences from '@ohos.data.preferences'
## 属性 ## 属性
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。<br>**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core | | MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。 |
| MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。<br>**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core | | MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。 |
## data_Preferences.getPreferences ## data_Preferences.getPreferences
...@@ -89,7 +91,7 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt; ...@@ -89,7 +91,7 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt;
## data_Preferences.deletePreferences ## data_Preferences.deletePreferences
deletePreferences(context: Context, name: string, callback: AsyncCallback&lt;void&gt;) deletePreferences(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void
从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。
...@@ -150,7 +152,7 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt; ...@@ -150,7 +152,7 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt;
## data_Preferences.removePreferencesFromCache ## data_Preferences.removePreferencesFromCache
removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback&lt;Preferences&gt;): void removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void
从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。
...@@ -163,7 +165,7 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba ...@@ -163,7 +165,7 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | Context | 是 | 应用程序或功能的上下文 | | context | Context | 是 | 应用程序或功能的上下文 |
| name | string | 是 | 应用程序内部数据存储名称。 | | name | string | 是 | 应用程序内部数据存储名称。 |
| callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
- 示例: - 示例:
``` ```
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 从API Version 9开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md) > 从API Version 9开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md)
...@@ -13,25 +15,24 @@ ...@@ -13,25 +15,24 @@
import dataStorage from '@ohos.data.storage' import dataStorage from '@ohos.data.storage'
``` ```
## 系统能力
SystemCapability.DistributedDataManager.Preferences.Core
## 属性 ## 属性
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。 | | MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。 |
| MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。 | | MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。 |
## dataStorage.getStorageSync<sup>(deprecated) </sup> ## dataStorage.getStorageSync
getStorageSync(path: string): Storage getStorageSync(path: string): Storage
读取指定文件,将数据加载到Storage实例,用于数据操作,此方法为同步方法。 读取指定文件,将数据加载到Storage实例,用于数据操作,此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -55,12 +56,14 @@ getStorageSync(path: string): Storage ...@@ -55,12 +56,14 @@ getStorageSync(path: string): Storage
``` ```
## dataStorage.getStorage<sup>(deprecated) </sup> ## dataStorage.getStorage
getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void
读取指定文件,将数据加载到Storage实例,用于数据操作,使用callback形式返回结果。 读取指定文件,将数据加载到Storage实例,用于数据操作,使用callback形式返回结果。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -85,12 +88,14 @@ getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void ...@@ -85,12 +88,14 @@ getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void
``` ```
## dataStorage.getStorage<sup>(deprecated) </sup> ## dataStorage.getStorage
getStorage(path: string): Promise&lt;Storage&gt; getStorage(path: string): Promise&lt;Storage&gt;
读取指定文件,将数据加载到Storage实例,用于数据操作,使用Promise方式作为异步方法。 读取指定文件,将数据加载到Storage实例,用于数据操作,使用Promise方式作为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -118,12 +123,14 @@ getStorage(path: string): Promise&lt;Storage&gt; ...@@ -118,12 +123,14 @@ getStorage(path: string): Promise&lt;Storage&gt;
``` ```
## dataStorage.deleteStorageSync<sup>(deprecated) </sup> ## dataStorage.deleteStorageSync
deleteStorageSync(path: string): void deleteStorageSync(path: string): void
从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,此方法为同步方法。 从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -135,12 +142,14 @@ deleteStorageSync(path: string): void ...@@ -135,12 +142,14 @@ deleteStorageSync(path: string): void
``` ```
## dataStorage.deleteStorage<sup>(deprecated) </sup> ## dataStorage.deleteStorage
deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;) deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;): void
从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -159,12 +168,14 @@ deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;) ...@@ -159,12 +168,14 @@ deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;)
``` ```
## dataStorage.deleteStorage<sup>(deprecated) </sup> ## dataStorage.deleteStorage
deleteStorage(path: string): Promise&lt;void&gt; deleteStorage(path: string): Promise&lt;void&gt;
从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。 从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -186,7 +197,7 @@ deleteStorage(path: string): Promise&lt;void&gt; ...@@ -186,7 +197,7 @@ deleteStorage(path: string): Promise&lt;void&gt;
``` ```
## dataStorage.removeStorageFromCacheSync<sup>(deprecated) </sup> ## dataStorage.removeStorageFromCacheSync
removeStorageFromCacheSync(path: string): void removeStorageFromCacheSync(path: string): void
...@@ -194,6 +205,8 @@ removeStorageFromCacheSync(path: string): void ...@@ -194,6 +205,8 @@ removeStorageFromCacheSync(path: string): void
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -205,19 +218,21 @@ removeStorageFromCacheSync(path: string): void ...@@ -205,19 +218,21 @@ removeStorageFromCacheSync(path: string): void
``` ```
## dataStorage.removeStorageFromCache<sup>(deprecated) </sup> ## dataStorage.removeStorageFromCache
removeStorageFromCache(path: string, callback: AsyncCallback&lt;Storage&gt;): void removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void
从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| path | string | 是 | 应用程序内部数据存储路径。 | | path | string | 是 | 应用程序内部数据存储路径。 |
| callback | AsyncCallback&lt;[Storage](#storage)&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
- 示例: - 示例:
``` ```
...@@ -231,7 +246,7 @@ removeStorageFromCache(path: string, callback: AsyncCallback&lt;Storage&gt;): vo ...@@ -231,7 +246,7 @@ removeStorageFromCache(path: string, callback: AsyncCallback&lt;Storage&gt;): vo
``` ```
## dataStorage.removeStorageFromCache<sup>(deprecated) </sup> ## dataStorage.removeStorageFromCache
removeStorageFromCache(path: string): Promise&lt;void&gt; removeStorageFromCache(path: string): Promise&lt;void&gt;
...@@ -239,6 +254,8 @@ removeStorageFromCache(path: string): Promise&lt;void&gt; ...@@ -239,6 +254,8 @@ removeStorageFromCache(path: string): Promise&lt;void&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -260,12 +277,12 @@ removeStorageFromCache(path: string): Promise&lt;void&gt; ...@@ -260,12 +277,12 @@ removeStorageFromCache(path: string): Promise&lt;void&gt;
``` ```
## Storage<sup>(deprecated) </sup> ## Storage
提供获取和修改存储数据的接口。 提供获取和修改存储数据的接口。
### getSync<sup>(deprecated) </sup> ### getSync
getSync(key: string, defValue: ValueType): ValueType getSync(key: string, defValue: ValueType): ValueType
...@@ -273,6 +290,8 @@ getSync(key: string, defValue: ValueType): ValueType ...@@ -273,6 +290,8 @@ getSync(key: string, defValue: ValueType): ValueType
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -291,7 +310,7 @@ getSync(key: string, defValue: ValueType): ValueType ...@@ -291,7 +310,7 @@ getSync(key: string, defValue: ValueType): ValueType
``` ```
### get<sup>(deprecated) </sup> ### get
get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void
...@@ -299,6 +318,8 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): ...@@ -299,6 +318,8 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;):
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -318,7 +339,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): ...@@ -318,7 +339,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;):
``` ```
### get<sup>(deprecated) </sup> ### get
get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
...@@ -326,6 +347,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; ...@@ -326,6 +347,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- **参数:** - **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -348,7 +371,7 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; ...@@ -348,7 +371,7 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
``` ```
### putSync<sup>(deprecated) </sup> ### putSync
putSync(key: string, value: ValueType): void putSync(key: string, value: ValueType): void
...@@ -356,6 +379,8 @@ putSync(key: string, value: ValueType): void ...@@ -356,6 +379,8 @@ putSync(key: string, value: ValueType): void
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -368,7 +393,7 @@ putSync(key: string, value: ValueType): void ...@@ -368,7 +393,7 @@ putSync(key: string, value: ValueType): void
``` ```
### put<sup>(deprecated) </sup> ### put
put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
...@@ -376,6 +401,8 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void ...@@ -376,6 +401,8 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -395,7 +422,7 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void ...@@ -395,7 +422,7 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
``` ```
### put<sup>(deprecated) </sup> ### put
put(key: string, value: ValueType): Promise&lt;void&gt; put(key: string, value: ValueType): Promise&lt;void&gt;
...@@ -403,6 +430,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt; ...@@ -403,6 +430,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -425,7 +454,7 @@ put(key: string, value: ValueType): Promise&lt;void&gt; ...@@ -425,7 +454,7 @@ put(key: string, value: ValueType): Promise&lt;void&gt;
``` ```
### hasSync<sup>(deprecated) </sup> ### hasSync
hasSync(key: string): boolean hasSync(key: string): boolean
...@@ -433,6 +462,8 @@ hasSync(key: string): boolean ...@@ -433,6 +462,8 @@ hasSync(key: string): boolean
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -452,7 +483,7 @@ hasSync(key: string): boolean ...@@ -452,7 +483,7 @@ hasSync(key: string): boolean
``` ```
### has<sup>(deprecated) </sup> ### has
has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
...@@ -460,6 +491,8 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean ...@@ -460,6 +491,8 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -485,7 +518,7 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean ...@@ -485,7 +518,7 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
``` ```
### has<sup>(deprecated) </sup> ### has
has(key: string): Promise&lt;boolean&gt; has(key: string): Promise&lt;boolean&gt;
...@@ -493,6 +526,8 @@ has(key: string): Promise&lt;boolean&gt; ...@@ -493,6 +526,8 @@ has(key: string): Promise&lt;boolean&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -516,7 +551,7 @@ has(key: string): Promise&lt;boolean&gt; ...@@ -516,7 +551,7 @@ has(key: string): Promise&lt;boolean&gt;
``` ```
### deleteSync<sup>(deprecated) </sup> ### deleteSync
deleteSync(key: string): void deleteSync(key: string): void
...@@ -524,6 +559,8 @@ deleteSync(key: string): void ...@@ -524,6 +559,8 @@ deleteSync(key: string): void
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -535,7 +572,7 @@ deleteSync(key: string): void ...@@ -535,7 +572,7 @@ deleteSync(key: string): void
``` ```
### delete<sup>(deprecated) </sup> ### delete
delete(key: string, callback: AsyncCallback&lt;void&gt;): void delete(key: string, callback: AsyncCallback&lt;void&gt;): void
...@@ -543,6 +580,8 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -543,6 +580,8 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -561,7 +600,7 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -561,7 +600,7 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void
``` ```
### delete<sup>(deprecated) </sup> ### delete
delete(key: string): Promise&lt;void&gt; delete(key: string): Promise&lt;void&gt;
...@@ -569,6 +608,8 @@ delete(key: string): Promise&lt;void&gt; ...@@ -569,6 +608,8 @@ delete(key: string): Promise&lt;void&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -590,7 +631,7 @@ delete(key: string): Promise&lt;void&gt; ...@@ -590,7 +631,7 @@ delete(key: string): Promise&lt;void&gt;
``` ```
### flushSync<sup>(deprecated) </sup> ### flushSync
flushSync(): void flushSync(): void
...@@ -598,13 +639,15 @@ flushSync(): void ...@@ -598,13 +639,15 @@ flushSync(): void
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 示例: - 示例:
``` ```
storage.flushSync() storage.flushSync()
``` ```
### flush<sup>(deprecated) </sup> ### flush
flush(callback: AsyncCallback&lt;void&gt;): void flush(callback: AsyncCallback&lt;void&gt;): void
...@@ -612,6 +655,8 @@ flush(callback: AsyncCallback&lt;void&gt;): void ...@@ -612,6 +655,8 @@ flush(callback: AsyncCallback&lt;void&gt;): void
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -629,7 +674,7 @@ flush(callback: AsyncCallback&lt;void&gt;): void ...@@ -629,7 +674,7 @@ flush(callback: AsyncCallback&lt;void&gt;): void
``` ```
### flush<sup>(deprecated) </sup> ### flush
flush(): Promise&lt;void&gt; flush(): Promise&lt;void&gt;
...@@ -637,6 +682,8 @@ flush(): Promise&lt;void&gt; ...@@ -637,6 +682,8 @@ flush(): Promise&lt;void&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
...@@ -653,7 +700,7 @@ flush(): Promise&lt;void&gt; ...@@ -653,7 +700,7 @@ flush(): Promise&lt;void&gt;
``` ```
### clearSync<sup>(deprecated) </sup> ### clearSync
clearSync(): void clearSync(): void
...@@ -661,13 +708,15 @@ clearSync(): void ...@@ -661,13 +708,15 @@ clearSync(): void
此方法为同步方法。 此方法为同步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 示例: - 示例:
``` ```
storage.clearSync() storage.clearSync()
``` ```
### clear<sup>(deprecated) </sup> ### clear
clear(callback: AsyncCallback&lt;void&gt;): void clear(callback: AsyncCallback&lt;void&gt;): void
...@@ -675,6 +724,8 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -675,6 +724,8 @@ clear(callback: AsyncCallback&lt;void&gt;): void
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -692,7 +743,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -692,7 +743,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void
``` ```
### clear<sup>(deprecated) </sup> ### clear
clear(): Promise&lt;void&gt; clear(): Promise&lt;void&gt;
...@@ -700,6 +751,8 @@ clear(): Promise&lt;void&gt; ...@@ -700,6 +751,8 @@ clear(): Promise&lt;void&gt;
此方法为异步方法。 此方法为异步方法。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
...@@ -716,12 +769,14 @@ clear(): Promise&lt;void&gt; ...@@ -716,12 +769,14 @@ clear(): Promise&lt;void&gt;
``` ```
### on('change')<sup>(deprecated) </sup> ### on('change')
on(type: 'change', callback: Callback&lt;StorageObserver&gt;): void on(type: 'change', callback: Callback&lt;StorageObserver&gt;): void
订阅数据变更者类需要实现StorageObserver接口,订阅的key的值发生变更后,在执行flush/flushSync方法后,callback方法会被回调。 订阅数据变更者类需要实现StorageObserver接口,订阅的key的值发生变更后,在执行flush/flushSync方法后,callback方法会被回调。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 说明 | | 参数名 | 类型 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -739,12 +794,14 @@ on(type: 'change', callback: Callback&lt;StorageObserver&gt;): void ...@@ -739,12 +794,14 @@ on(type: 'change', callback: Callback&lt;StorageObserver&gt;): void
``` ```
### off('change')<sup>(deprecated) </sup> ### off('change')
off(type: 'change', callback: Callback&lt;StorageObserver&gt;): void off(type: 'change', callback: Callback&lt;StorageObserver&gt;): void
当不再进行订阅数据变更时,使用此接口取消订阅。 当不再进行订阅数据变更时,使用此接口取消订阅。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
- 参数: - 参数:
| 参数名 | 类型 | 说明 | | 参数名 | 类型 | 说明 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -760,7 +817,9 @@ off(type: 'change', callback: Callback&lt;StorageObserver&gt;): void ...@@ -760,7 +817,9 @@ off(type: 'change', callback: Callback&lt;StorageObserver&gt;): void
``` ```
## StorageObserver<sup>(deprecated) </sup> ## StorageObserver
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 参数类型 | 必填 | 说明 | | 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册