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

!13784 【datashare】monthly使用最新rdb接口

Merge pull request !13784 from 牛东尧/monthly_20221018
......@@ -42,7 +42,7 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其
```ts
import Extension from '@ohos.application.DataShareExtensionAbility';
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
import fileIo from '@ohos.fileio';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
......@@ -69,8 +69,9 @@ DataShare即数据共享模块,提供了向其他应用共享以及管理其
result = this.context.cacheDir + '/datashare.txt'
// 业务实现使用RDB
rdb.getRdbStore(this.context, {
name: DB_NAME
}, 1, function (err, data) {
name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1
}, function (err, data) {
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
console.log('DataShareExtAbility onCreate, executeSql done err:' + JSON.stringify(err));
......
......@@ -57,13 +57,13 @@ DataShare客户端连接DataShareExtensionAbility服务端时,服务端回调
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ------ | ------ |
| want | [Want](js-apis-application-want.md#want) | 是 | Want类型信息,包括ability名称、bundle名称等。 |
| want | [Want](js-apis-application-want.md#want) | 是 | Want类型信息,包括Ability名称、Bundle名称等。 |
| callback | AsyncCallback<void> | 是 | 回调函数。无返回值。 |
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -75,8 +75,9 @@ let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want, callback) {
rdb.getRdbStore(this.context, {
name: DB_NAME
}, 1, function (err, data) {
name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1
}, function (err, data) {
console.log('getRdbStore done, data : ' + data);
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
......@@ -109,7 +110,7 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -154,7 +155,7 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -196,7 +197,7 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -239,7 +240,7 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -284,7 +285,7 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy
**示例:**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册