Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6943b6e3
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6943b6e3
编写于
5月 13, 2022
作者:
P
PaDaBoo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updatefile
Signed-off-by:
N
PaDaBoo
<
xuejianwu@huawei.com
>
上级
40ccb569
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
22 deletion
+22
-22
zh-cn/application-dev/reference/apis/js-apis-data-preferences.md
...pplication-dev/reference/apis/js-apis-data-preferences.md
+22
-22
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-preferences.md
浏览文件 @
6943b6e3
...
...
@@ -15,7 +15,7 @@ import data_preferences from '@ohos.data.preferences';
## 常量
**系统能力:**
以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
...
...
@@ -30,7 +30,7 @@ getPreferences(context: Context, name: string, callback: AsyncCallback<Prefer
读取指定首选项持久化文件,将数据加载到Preferences实例,用于数据操作,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -57,7 +57,7 @@ getPreferences(context: Context, name: string): Promise<Preferences>
读取指定首选项持久化文件,将数据加载到Preferences实例,用于数据操作,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -88,7 +88,7 @@ deletePreferences(context: Context, name: string, callback: AsyncCallback<voi
从内存中移除指定首选项持久化文件对应的Preferences单实例,并删除指定文件及其备份文件和损坏文件。
删除指定首选项持久化文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -116,7 +116,7 @@ deletePreferences(context: Context, name: string): Promise<void>
从内存中移除指定首选项持久化文件对应的Preferences单实例,并删除指定文件及其备份文件和损坏文件。
删除指定首选项持久化文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -148,7 +148,7 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba
移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -177,7 +177,7 @@ removePreferencesFromCache(context: Context, name: string): Promise<void>
移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -212,7 +212,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>):
获取键对应的值,如果值为null或者非默认值类型,返回默认数据,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -239,7 +239,7 @@ get(key: string, defValue: ValueType): Promise<ValueType>
获取键对应的值,如果值为null或者非默认值类型,返回默认数据,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
-
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -269,7 +269,7 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void
首先获取指定首选项持久化文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -296,7 +296,7 @@ put(key: string, value: ValueType): Promise<void>
首先获取指定首选项持久化文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -326,7 +326,7 @@ has(key: string, callback: AsyncCallback<boolean>): boolean
检查存储对象是否包含名为给定key的存储键值对,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -361,7 +361,7 @@ has(key: string): Promise<boolean>
检查存储对象是否包含名为给定key的存储键值对,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -394,7 +394,7 @@ delete(key: string, callback: AsyncCallback<void>): void
从存储对象中删除名为给定key的存储键值对,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -420,7 +420,7 @@ delete(key: string): Promise<void>
从存储对象删除名为给定key的存储键值对,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -449,7 +449,7 @@ flush(callback: AsyncCallback<void>): void
将当前preferences对象中的修改保存到当前的preferences,并异步存储到首选项持久化文件中,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -474,7 +474,7 @@ flush(): Promise<void>
将当前preferences对象中的修改保存到当前的preferences,并异步存储到首选项持久化文件中,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**返回值:**
| 类型 | 说明 |
...
...
@@ -498,7 +498,7 @@ clear(callback: AsyncCallback<void>): void
清除此存储对象中的所有存储,该方法使用callback方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -523,7 +523,7 @@ clear(): Promise<void>
清除此存储对象中的所有存储,该方法使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**返回值:**
| 类型 | 说明 |
...
...
@@ -547,7 +547,7 @@ on(type: 'change', callback: Callback<{ key : string }>): void
订阅数据变更者类,订阅的key的值发生变更后,在执行flush方法后,callback方法会被回调。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 说明 |
...
...
@@ -588,7 +588,7 @@ off(type: 'change', callback: Callback<{ key : string }>): void
当不再进行订阅数据变更时,使用此接口取消订阅。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**参数:**
| 参数名 | 类型 | 说明 |
...
...
@@ -627,7 +627,7 @@ preferences.put('startup', 'auto', function (err) {
用于表示允许的数据字段类型。
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 说明 |
| ------- | -------------------- |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录