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

!13469 [翻译完成】#I63A6M

Merge pull request !13469 from Annie_wang/PR11856
......@@ -202,7 +202,7 @@
- [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.relationalStore](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
......@@ -339,6 +339,7 @@
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
- [@ohos.document](js-apis-document.md)
......
# @ohos.application.DataShareExtensionAbility
The **DataShareExtensionAbility** module provides extension abilities for data share services.
The **DataShareExtensionAbility** module provides data share services based on the Extension ability.
>**NOTE**
>
......@@ -17,6 +17,27 @@ The **DataShareExtensionAbility** module provides extension abilities for data s
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'
```
## URI Naming Rule
The URIs are in the following format:
**Scheme://authority/path**
- *Scheme*: scheme name, which has a fixed value of **datashare** for the **DataShare** module.
- *authority*: [userinfo@]host[:port]
- *userinfo*: login information, which can be left unspecified.
- *host*: server address. It is the target device ID for cross-device access and empty for local device access.
- *port*: port number of the server, which can be left unspecified.
- *path*: **DataShare** identifier and the resource path. The **DataShare** identifier is mandatory, and the resource path is optional.
Example:
- URI without the resource path:<br>**datashare:///com.samples.datasharetest.DataShare**
- URI with the resource path:<br>**datashare:///com.samples.datasharetest.DataShare/DB00/TBL00**
**com.samples.datasharetest.DataShare** is the data share identifier, and **DB00/TBL00** is the resource path.
## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
......@@ -43,7 +64,7 @@ Called by the server to initialize service logic when the DataShare client conne
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -56,7 +77,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want, callback) {
rdb.getRdbStore(this.context, {
name: DB_NAME
}, 1, function (err, data) {
}, function (err, data) {
console.log('getRdbStore done, data : ' + data);
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
......@@ -89,7 +110,7 @@ Inserts data into the database. This API can be overridden as required.
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -134,7 +155,7 @@ Updates data in the database. This API can be overridden as required.
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -176,7 +197,7 @@ Deletes data from the database. This API can be overridden as required.
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -219,7 +240,7 @@ Queries data from the database. This API can be overridden as required.
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......@@ -264,7 +285,7 @@ Batch inserts data into the database. This API is called by the server and can b
**Example**
```ts
import rdb from '@ohos.data.rdb';
import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
......
# Data Share Result Set
# @ohos.data.dataShareResultSet
The **DataShareResultSet** module provides APIs for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type.
......
# DataShare Error Codes
## 15700010 Failed to Create a DataShareHelper
**Error Message**
The dataShareHelper is not initialized successfully.
**Description**
The **DataShareHelper** class fails to be created.
**Possible Causes**
1. The **uri** specified in **createDataHelper** is incorrect.
2. The **context** specified in **createDataHelper** is incorrect. **DataShare** supports only the stage model.
**Solution**
1. Obtain the correct URI.
2. Check that the context of the stage model is used.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册