diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index d7ae5228b898dc16f08a77500b57d683de3af23e..2a2f11b15669dc859e83283290be8b17e0f58b68 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -22,7 +22,8 @@ - [用户认证](js-apis-useriam-userauth.md) - [访问控制](js-apis-abilityAccessCtrl.md) - 数据管理 - - [轻量级存储](js-apis-data-storage.md) + - [轻量级存储](js-apis-data-preferences.md) + - [轻量级存储(废弃 since 8)](js-apis-data-storage.md) - [分布式数据管理](js-apis-distributed-data.md) - [关系型数据库](js-apis-data-rdb.md) - [结果集](js-apis-data-resultset.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md new file mode 100644 index 0000000000000000000000000000000000000000..543b429ce1ace53f963f89f2bf36a599690d8696 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -0,0 +1,625 @@ +# 轻量级存储 + +轻量级存储为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + +``` +import data_Preferences from '@ohos.data.preferences' +``` + +## 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| MAX_KEY_LENGTH | string | 是 | 否 | key的最大长度限制,大小为80字节。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core | +| MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。
**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core | + + +## data_Preferences.getPreferences + +### 系统能力 +SystemCapability.DistributedDataManager.Preferences.Core + +getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void + +读取指定文件,将数据加载到Preferences实例,用于数据操作,使用callback形式返回结果。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + | callback | AsyncCallback<[Preferences](#preferences)> | 是 | 回调函数。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + var path = await this.context.getDataBaseDir() + data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { + console.info("Get the preferences failed, path: " + path + '/mystore') + return; + } + preferences.putSync('startup', 'auto') + preferences.flushSync() + }) + ``` + + +## data_Preferences.getPreferences + +### 系统能力 +SystemCapability.DistributedDataManager.Preferences.Core + +getPreferences(context: Context, name: string): Promise<Preferences> + +读取指定文件,将数据加载到Preferences实例,用于数据操作,使用Promise方式作为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<[Preferences](#preferences)> | Promise实例,用于异步获取结果。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + var path = await this.context.getDataBaseDir() + let promise = data_Preferences.getPreferences(this.context, 'mystore') + promise.then((preferences) => { + preferences.putSync('startup', 'auto') + preferences.flushSync() + }).catch((err) => { + console.info("Get the preferences failed, path: " + path + '/mystore') + }) + ``` + + +## data_Preferences.deletePreferences + +### 系统能力 +SystemCapability.DistributedDataManager.Preferences.Core + +deletePreferences(context: Context, name: string, callback: AsyncCallback<void>) + +从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + data_Preferences.deletePreferences(this.context, 'mystore', function (err) { + if (err) { + console.info("Deleted failed with err: " + err) + return + } + console.info("Deleted successfully.") + }) + ``` + + +## data_Preferences.deletePreferences + +### 系统能力 +SystemCapability.DistributedDataManager.Preferences.Core + +deletePreferences(context: Context, name: string): Promise<void> + +从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步获取结果。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + let promise = data_Preferences.deletePreferences(this.context, 'mystore') + promise.then(() => { + console.info("Deleted successfully.") + }).catch((err) => { + console.info("Deleted failed with err: " + err) + }) + ``` + + +## data_Preferences.removePreferencesFromCache + +### 系统能力 +SystemCapability.DistributedDataManager.Preferences.Core + +removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<Preferences>): void + +从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + | callback | AsyncCallback<[Preferences](#preferences)> | 是 | 回调函数。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + data_Preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { + if (err) { + console.info("Removed preferences from cache failed with err: " + err) + return + } + console.info("Removed preferences from cache successfully.") + }) + ``` + + +## data_Preferences.removePreferencesFromCache + +### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +removePreferencesFromCache(context: Context, name: string): Promise<void> + +从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | context | Context | 是 | 应用程序或功能的上下文 | + | name | string | 是 | 应用程序内部数据存储名称。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步获取结果。 | + +- 示例: + ``` + import Ability from '@ohos.application.Ability' + import data_Preferences from '@ohos.data.preferences' + let promise = data_Preferences.removePreferencesFromCache(this.context, 'mystore') + promise.then(() => { + console.info("Removed preferences from cache successfully.") + }).catch((err) => { + console.info("Removed preferences from cache failed with err: " + err) + }) + ``` + + +## Preferences + +提供获取和修改存储数据的接口。 + + +### get + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void + +获取键对应的值,如果值为null或者非默认值类型,返回默认数据。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称。它不能为空。 | + | defValue | ValueType | 是 | 默认返回值。支持number、string、boolean。 | + | callback | AsyncCallback<ValueType> | 是 | 回调函数。 | + +- 示例: + ``` + preferences.get('startup', 'default', function(err, value) { + if (err) { + console.info("Get the value of startup failed with err: " + err) + return + } + console.info("The value of startup is " + value) + }) + ``` + + +### get + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +get(key: string, defValue: ValueType): Promise<ValueType> + +获取键对应的值,如果值为null或者非默认值类型,返默认数据。 + +此方法为异步方法。 + +- **参数:** + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称。它不能为空。 | + | defValue | ValueType | 是 | 默认返回值。支持number、string、boolean。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<ValueType> | Promise实例,用于异步获取结果。 | + +- 示例: + ``` + let promise = preferences.get('startup', 'default') + promise.then((value) => { + console.info("The value of startup is " + value) + }).catch((err) => { + console.info("Get the value of startup failed with err: " + err) + }) + ``` + + +### put + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +put(key: string, value: ValueType, callback: AsyncCallback<void>): void + +首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要修改的存储的key。它不能为空。 | + | value | ValueType | 是 | 存储的新值。支持number、string、boolean。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例: + ``` + preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Put the value of startup failed with err: " + err) + return + } + console.info("Put the value of startup successfully.") + }) + ``` + + +### put + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +put(key: string, value: ValueType): Promise<void> + +首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要修改的存储的key。它不能为空。 | + | value | ValueType | 是 | 存储的新值。支持number、string、boolean。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步处理。 | + +- 示例: + ``` + let promise = preferences.put('startup', 'auto') + promise.then(() => { + console.info("Put the value of startup successfully.") + }).catch((err) => { + console.info("Put the value of startup failed with err: " + err) + }) + ``` + + +### has + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +has(key: string, callback: AsyncCallback<boolean>): boolean + +检查存储对象是否包含名为给定key的存储。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称,不能为空。 | + | callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | true表示存在,false表示不存在。 | + +- 示例: + ``` + preferences.has('startup', function (err, isExist) { + if (err) { + console.info("Check the key of startup failed with err: " + err) + return + } + if (isExist) { + console.info("The key of startup is contained.") + } + }) + ``` + + +### has + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +has(key: string): Promise<boolean> + +检查存储对象是否包含名为给定key的存储。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称。它不能为空。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | Promise实例,用于异步处理。 | + +- 示例: + ``` + let promise = preferences.has('startup') + promise.then((isExist) => { + if (isExist) { + console.info("The key of startup is contained.") + } + }).catch((err) => { + console.info("Check the key of startup failed with err: " + err) + }) + ``` + + +### delete + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +delete(key: string, callback: AsyncCallback<void>): void + +从存储对象中删除名为给定key的存储。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称,不能为空。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例: + ``` + preferences.delete('startup', function (err) { + if (err) { + console.info("Delete startup key failed with err: " + err) + return + } + console.info("Deleted startup key successfully.") + }) + ``` + + +### delete + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +delete(key: string): Promise<void> + +从存储对象删除名为给定key的存储。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | key | string | 是 | 要获取的存储key名称。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步处理。 | + +- 示例: + ``` + let promise = preferences.delete('startup') + promise.then(() => { + console.info("Deleted startup key successfully.") + }).catch((err) => { + console.info("Delete startup key failed with err: " + err) + }) + ``` + + +### flush + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +flush(callback: AsyncCallback<void>): void + +将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例: + ``` + preferences.flush(function (err) { + if (err) { + console.info("Flush to file failed with err: " + err) + return + } + console.info("Flushed to file successfully.") + }) + ``` + + +### flush + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +flush(): Promise<void> + +将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 + +此方法为异步方法。 + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步处理。 | + +- 示例: + ``` + let promise = preferences.flush() + promise.then(() => { + console.info("Flushed to file successfully.") + }).catch((err) => { + console.info("Flush to file failed with err: " + err) + }) + ``` + + +### clear + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +clear(callback: AsyncCallback<void>): void + +清除此存储对象中的所有存储。 + +此方法为异步方法。 + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例: + ``` + preferences.clear(function (err) { + if (err) { + console.info("Clear to file failed with err: " + err) + return + } + console.info("Cleared to file successfully.") + }) + ``` + + +### clear + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +clear(): Promise<void> + +清除此存储对象中的所有存储。 + +此方法为异步方法。 + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于异步处理。 | + +- 示例: + ``` + let promise = preferences.clear() + promise.then(() => { + console.info("Cleared to file successfully.") + }).catch((err) => { + console.info("Clear to file failed with err: " + err) + }) + ``` + + +### on('change') + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +on(type: 'change', callback: Callback<{ key : string }>): void + +订阅数据变更者类,订阅的key的值发生变更后,在执行flush方法后,callback方法会被回调。 + +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | type | string | 事件类型,固定值'change',表示数据变更。 | + | callback | Callback<{ key : string }> | 回调对象实例。 | + +- 示例: + ``` + var observer = function (key) { + console.info("The key of " + key + " changed.") + } + preferences.on('change', observer) + preferences.put('startup', 'auto') + preferences.flush() // observer will be called. + ``` + + +### off('change') + +#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core + +off(type: 'change', callback: Callback<{ key : string }>): void + +当不再进行订阅数据变更时,使用此接口取消订阅。 + +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | type | string | 事件类型,固定值'change',表示数据变更。 | + | callback | Callback<{ key : string }> | 需要取消的回调对象实例。 | + +- 示例: + ``` + var observer = function (key) { + console.info("The key of " + key + " changed.") + } + preferences.off('change', observer) + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index 36a5d185fc3bf69e4ea7ced2880a19dcd5623563..8c47d4e3531f3e22994791e2b625bfde70566387 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -4,7 +4,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API Version 8开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md) ## 导入模块 @@ -26,7 +26,7 @@ SystemCapability.DistributedDataManager.Preferences.Core | MAX_VALUE_LENGTH | string | 是 | 否 | string类型value的最大长度限制,大小为8192字节。 | -## dataStorage.getStorageSync +## dataStorage.getStorageSync(deprecated) getStorageSync(path: string): Storage @@ -46,7 +46,7 @@ getStorageSync(path: string): Storage ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() let storage = dataStorage.getStorageSync(path + '/mystore') @@ -55,7 +55,7 @@ getStorageSync(path: string): Storage ``` -## dataStorage.getStorage +## dataStorage.getStorage(deprecated) getStorage(path: string, callback: AsyncCallback<Storage>): void @@ -71,7 +71,7 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() dataStorage.getStorage(path + '/mystore', function (err, storage) { @@ -85,7 +85,7 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void ``` -## dataStorage.getStorage +## dataStorage.getStorage(deprecated) getStorage(path: string): Promise<Storage> @@ -105,7 +105,7 @@ getStorage(path: string): Promise<Storage> ``` import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - + var context = featureAbility.getContext() var path = await context.getFilesDir() let promise = dataStorage.getStorage(path + '/mystore') @@ -118,7 +118,7 @@ getStorage(path: string): Promise<Storage> ``` -## dataStorage.deleteStorageSync +## dataStorage.deleteStorageSync(deprecated) deleteStorageSync(path: string): void @@ -135,7 +135,7 @@ deleteStorageSync(path: string): void ``` -## dataStorage.deleteStorage +## dataStorage.deleteStorage(deprecated) deleteStorage(path: string, callback: AsyncCallback<void>) @@ -159,7 +159,7 @@ deleteStorage(path: string, callback: AsyncCallback<void>) ``` -## dataStorage.deleteStorage +## dataStorage.deleteStorage(deprecated) deleteStorage(path: string): Promise<void> @@ -186,7 +186,7 @@ deleteStorage(path: string): Promise<void> ``` -## dataStorage.removeStorageFromCacheSync +## dataStorage.removeStorageFromCacheSync(deprecated) removeStorageFromCacheSync(path: string): void @@ -205,7 +205,7 @@ removeStorageFromCacheSync(path: string): void ``` -## dataStorage.removeStorageFromCache +## dataStorage.removeStorageFromCache(deprecated) removeStorageFromCache(path: string, callback: AsyncCallback<Storage>): void @@ -231,7 +231,7 @@ removeStorageFromCache(path: string, callback: AsyncCallback<Storage>): vo ``` -## dataStorage.removeStorageFromCache +## dataStorage.removeStorageFromCache(deprecated) removeStorageFromCache(path: string): Promise<void> @@ -260,12 +260,12 @@ removeStorageFromCache(path: string): Promise<void> ``` -## Storage +## Storage(deprecated) 提供获取和修改存储数据的接口。 -### getSync +### getSync(deprecated) getSync(key: string, defValue: ValueType): ValueType @@ -291,7 +291,7 @@ getSync(key: string, defValue: ValueType): ValueType ``` -### get +### get(deprecated) get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void @@ -318,7 +318,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): ``` -### get +### get(deprecated) get(key: string, defValue: ValueType): Promise<ValueType> @@ -348,7 +348,7 @@ get(key: string, defValue: ValueType): Promise<ValueType> ``` -### putSync +### putSync(deprecated) putSync(key: string, value: ValueType): void @@ -368,7 +368,7 @@ putSync(key: string, value: ValueType): void ``` -### put +### put(deprecated) put(key: string, value: ValueType, callback: AsyncCallback<void>): void @@ -395,7 +395,7 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void ``` -### put +### put(deprecated) put(key: string, value: ValueType): Promise<void> @@ -425,7 +425,7 @@ put(key: string, value: ValueType): Promise<void> ``` -### hasSync +### hasSync(deprecated) hasSync(key: string): boolean @@ -452,7 +452,7 @@ hasSync(key: string): boolean ``` -### has +### has(deprecated) has(key: string, callback: AsyncCallback<boolean>): boolean @@ -485,7 +485,7 @@ has(key: string, callback: AsyncCallback<boolean>): boolean ``` -### has +### has(deprecated) has(key: string): Promise<boolean> @@ -516,7 +516,7 @@ has(key: string): Promise<boolean> ``` -### deleteSync +### deleteSync(deprecated) deleteSync(key: string): void @@ -535,7 +535,7 @@ deleteSync(key: string): void ``` -### delete +### delete(deprecated) delete(key: string, callback: AsyncCallback<void>): void @@ -561,7 +561,7 @@ delete(key: string, callback: AsyncCallback<void>): void ``` -### delete +### delete(deprecated) delete(key: string): Promise<void> @@ -590,7 +590,7 @@ delete(key: string): Promise<void> ``` -### flushSync +### flushSync(deprecated) flushSync(): void @@ -604,7 +604,7 @@ flushSync(): void ``` -### flush +### flush(deprecated) flush(callback: AsyncCallback<void>): void @@ -629,7 +629,7 @@ flush(callback: AsyncCallback<void>): void ``` -### flush +### flush(deprecated) flush(): Promise<void> @@ -653,7 +653,7 @@ flush(): Promise<void> ``` -### clearSync +### clearSync(deprecated) clearSync(): void @@ -667,7 +667,7 @@ clearSync(): void ``` -### clear +### clear(deprecated) clear(callback: AsyncCallback<void>): void @@ -692,7 +692,7 @@ clear(callback: AsyncCallback<void>): void ``` -### clear +### clear(deprecated) clear(): Promise<void> @@ -716,7 +716,7 @@ clear(): Promise<void> ``` -### on('change') +### on('change')(deprecated) on(type: 'change', callback: Callback<StorageObserver>): void @@ -739,7 +739,7 @@ on(type: 'change', callback: Callback<StorageObserver>): void ``` -### off('change') +### off('change')(deprecated) off(type: 'change', callback: Callback<StorageObserver>): void @@ -760,7 +760,7 @@ off(type: 'change', callback: Callback<StorageObserver>): void ``` -## StorageObserver +## StorageObserver(deprecated) | 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/website-directory.md b/zh-cn/website-directory.md index 38ddb94c81f4edf0ec83cdbc235437bb434e6225..97b716421778d8708ab316c1696984dd4476394d 100644 --- a/zh-cn/website-directory.md +++ b/zh-cn/website-directory.md @@ -1380,7 +1380,9 @@ ——>——>——>——> 数据管理 -——>——>——>——>——> [轻量级存储](application-dev/reference/apis/js-apis-data-storage.md) +——>——>——>——>——> [轻量级存储](application-dev/reference/apis/js-apis-data-preferences.md) + +——>——>——>——>——> [轻量级存储(废弃 since 8)](application-dev/reference/apis/js-apis-data-storage.md) ——>——>——>——>——> [分布式数据管理](application-dev/reference/apis/js-apis-distributed-data.md)