提交 0ad5326f 编写于 作者: L liusaimei

dataShare相关使用说明文档示例代码ArkTs规范整改

Signed-off-by: Nliusaimei <liusaimei@huawei.com>
上级 c7a8c61c
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
```ts ```ts
import Extension from '@ohos.application.DataShareExtensionAbility'; import Extension from '@ohos.application.DataShareExtensionAbility';
import rdb from '@ohos.data.relationalStore';
import dataSharePredicates from '@ohos.data.dataSharePredicates'; import dataSharePredicates from '@ohos.data.dataSharePredicates';
import relationalStore from '@ohos.data.relationalStore'; import relationalStore from '@ohos.data.relationalStore';
import Want from '@ohos.app.ability.Want'; import Want from '@ohos.app.ability.Want';
...@@ -86,9 +85,9 @@ ...@@ -86,9 +85,9 @@
onCreate(want: Want, callback: Function) { onCreate(want: Want, callback: Function) {
result = this.context.cacheDir + '/datashare.txt'; result = this.context.cacheDir + '/datashare.txt';
// 业务实现使用RDB // 业务实现使用RDB
rdb.getRdbStore(this.context, { relationalStore.getRdbStore(this.context, {
name: DB_NAME, name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1 securityLevel: relationalStore.SecurityLevel.S1
}, (err, data) => { }, (err, data) => {
rdbStore = data; rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => { rdbStore.executeSql(DDL_TBL_CREATE, [], (err) => {
...@@ -220,7 +219,7 @@ ...@@ -220,7 +219,7 @@
4. 获取到接口类对象后,便可利用其提供的接口访问提供方提供的服务,如进行数据的增删改查等。 4. 获取到接口类对象后,便可利用其提供的接口访问提供方提供的服务,如进行数据的增删改查等。
```ts ```ts
// 构建一条数据 // 构建一条数据
let key1 = 'name'; let key1 = 'name';
let key2 = 'age'; let key2 = 'age';
......
...@@ -55,7 +55,7 @@ let rdbStore: relationalStore.RdbStore; ...@@ -55,7 +55,7 @@ let rdbStore: relationalStore.RdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility { export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want: Want, callback: Function) { onCreate(want: Want, callback: Function) {
relationalStore.getRdbStore(globalThis.getContext(), { relationalStore.getRdbStore(this.context, {
name: DB_NAME, name: DB_NAME,
securityLevel: relationalStore.SecurityLevel.S1 securityLevel: relationalStore.SecurityLevel.S1
}, (err, data) => { }, (err, data) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册