未验证 提交 ce05d05e 编写于 作者: O openharmony_ci 提交者: Gitee

!9332 分布式数据管理文档错误修改

Merge pull request !9332 from lpeydb/master
...@@ -45,55 +45,50 @@ Stage模型下的示例: ...@@ -45,55 +45,50 @@ Stage模型下的示例:
import AbilityStage from '@ohos.application.Ability' import AbilityStage from '@ohos.application.Ability'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("MyAbilityStage onCreate") console.log("MyAbilityStage onCreate")
let context = this.context let context = this.context
const kvManagerConfig = { const kvManagerConfig = {
context: context, context: context,
bundleName: 'com.example.datamanagertest', bundleName: 'com.example.datamanagertest',
userInfo: { userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
}
} }
``` ```
FA模型下的示例: FA模型下的示例:
```js ```js
import AbilityStage from '@ohos.application.Ability' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = this.context bundleName: 'com.example.datamanagertest',
const kvManagerConfig = { userInfo: {
context: context.getApplicationContext(),
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
}
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) { }
if (err) { distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err)); console.log("Failed to create KVManager: " + JSON.stringify(err));
return; return;
} }
console.log("Succeeded in creating KVManager"); console.log("Created KVManager");
kvManager = manager; kvManager = manager;
}); });
}
}
``` ```
## distributedData.createKVManager ## distributedData.createKVManager
...@@ -123,55 +118,46 @@ Stage模型下的示例: ...@@ -123,55 +118,46 @@ Stage模型下的示例:
import AbilityStage from '@ohos.application.Ability' import AbilityStage from '@ohos.application.Ability'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("MyAbilityStage onCreate") console.log("MyAbilityStage onCreate")
let context = this.context let context = this.context
const kvManagerConfig = { const kvManagerConfig = {
context: context, context: context,
bundleName: 'com.example.datamanagertest', bundleName: 'com.example.datamanagertest',
userInfo: { userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
}
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Succeeded in creating KVManager");
kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
});
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
}
} }
``` ```
FA模型下的示例: FA模型下的示例:
```js ```js
import AbilityStage from '@ohos.application.Ability' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = this.context bundleName: 'com.example.datamanagertest',
const kvManagerConfig = { userInfo: {
context: context.getApplicationContext(),
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
}
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Succeeded in creating KVManager");
kvManager = manager;
});
}
} }
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Succeeded in creating KVManager");
kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
});
``` ```
## KVManagerConfig ## KVManagerConfig
...@@ -666,16 +652,14 @@ KVStore数据库类型枚举。 ...@@ -666,16 +652,14 @@ KVStore数据库类型枚举。
数据库的安全级别枚举。 数据库的安全级别枚举。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| --- | ---- | ----------------------- | | --- | ---- | ----------------------- |
| NO_LEVEL | 0 | 表示数据库不设置安全级别。 | | NO_LEVEL | 0 | 表示数据库不设置安全级别。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| S0 | 1 | 表示数据库的安全级别为公共级别。 | | S0 | 1 | 表示数据库的安全级别为公共级别。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core |
| S1 | 2 | 表示数据库的安全级别为低级别,当数据泄露时会产生较低影响。例如,包含壁纸等系统数据的数据库。 | | S1 | 2 | 表示数据库的安全级别为低级别,当数据泄露时会产生较低影响。例如,包含壁纸等系统数据的数据库。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core |
| S2 | 3 | 表示数据库的安全级别为中级别,当数据泄露时会产生较大影响。例如,包含录音、视频等用户生成数据或通话记录等信息的数据库。 | | S2 | 3 | 表示数据库的安全级别为中级别,当数据泄露时会产生较大影响。例如,包含录音、视频等用户生成数据或通话记录等信息的数据库。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core |
| S3 | 5 | 表示数据库的安全级别为高级别,当数据泄露时会产生重大影响。例如,包含用户运动、健康、位置等信息的数据库。 | | S3 | 5 | 表示数据库的安全级别为高级别,当数据泄露时会产生重大影响。例如,包含用户运动、健康、位置等信息的数据库。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core |
| S4 | 6 | 表示数据库的安全级别为关键级别,当数据泄露时会产生严重影响。例如,包含认证凭据、财务数据等信息的数据库。 | | S4 | 6 | 表示数据库的安全级别为关键级别,当数据泄露时会产生严重影响。例如,包含认证凭据、财务数据等信息的数据库。<br>**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core |
## Constants ## Constants
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册