提交 223abcfc 编写于 作者: S siyuan.liu

update js-apis-distributed-data.md

Signed-off-by: Nsiyuan.liu <siyuan.liu@unionman.com.cn>
上级 e5c05ab2
......@@ -72,28 +72,23 @@ FA模型下的示例:
```js
import featureAbility from '@ohos.ability.featureAbility'
let kvManager;
export default class MyAbility {
onCreate() {
console.log("MyAbilityStage onCreate")
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
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("Created KVManager");
kvManager = manager;
});
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
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("Created KVManager");
kvManager = manager;
});
```
## distributedData.createKVManager
......@@ -148,26 +143,21 @@ FA模型下的示例:
```js
import featureAbility from '@ohos.ability.featureAbility'
let kvManager;
export default class MyAbility {
onCreate() {
console.log("MyAbilityStage onCreate")
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
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));
});
let context = featureAbility.getContext()
const kvManagerConfig = {
context: context,
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
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));
});
```
## KVManagerConfig
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册