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

!13469 [翻译完成】#I63A6M

Merge pull request !13469 from Annie_wang/PR11856
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
- [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.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) - [@ohos.data.ValuesBucket](js-apis-data-valuesBucket.md)
- data/rdb - data/rdb
- [resultSet](js-apis-data-resultset.md) - [resultSet](js-apis-data-resultset.md)
...@@ -339,6 +339,7 @@ ...@@ -339,6 +339,7 @@
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md) - [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md) - [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.data.storage](js-apis-data-storage.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.data.distributedData](js-apis-distributed-data.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md) - [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
- [@ohos.document](js-apis-document.md) - [@ohos.document](js-apis-document.md)
......
# @ohos.application.DataShareExtensionAbility # @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** >**NOTE**
> >
...@@ -17,13 +17,34 @@ The **DataShareExtensionAbility** module provides extension abilities for data s ...@@ -17,13 +17,34 @@ The **DataShareExtensionAbility** module provides extension abilities for data s
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility' 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 ## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider **System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes| No|Context of the DataShare Extension ability.| | context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes| No|Context of the DataShare Extension ability.|
## onCreate ## onCreate
...@@ -43,7 +64,7 @@ Called by the server to initialize service logic when the DataShare client conne ...@@ -43,7 +64,7 @@ Called by the server to initialize service logic when the DataShare client conne
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; let TBL_NAME = "TBL00";
...@@ -56,7 +77,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { ...@@ -56,7 +77,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want, callback) { onCreate(want, callback) {
rdb.getRdbStore(this.context, { rdb.getRdbStore(this.context, {
name: DB_NAME name: DB_NAME
}, 1, function (err, data) { }, function (err, data) {
console.log('getRdbStore done, data : ' + data); console.log('getRdbStore done, data : ' + data);
rdbStore = data; rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
...@@ -89,7 +110,7 @@ Inserts data into the database. This API can be overridden as required. ...@@ -89,7 +110,7 @@ Inserts data into the database. This API can be overridden as required.
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; let TBL_NAME = "TBL00";
...@@ -134,7 +155,7 @@ Updates data in the database. This API can be overridden as required. ...@@ -134,7 +155,7 @@ Updates data in the database. This API can be overridden as required.
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; let TBL_NAME = "TBL00";
...@@ -176,7 +197,7 @@ Deletes data from the database. This API can be overridden as required. ...@@ -176,7 +197,7 @@ Deletes data from the database. This API can be overridden as required.
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; let TBL_NAME = "TBL00";
...@@ -219,7 +240,7 @@ Queries data from the database. This API can be overridden as required. ...@@ -219,7 +240,7 @@ Queries data from the database. This API can be overridden as required.
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; let TBL_NAME = "TBL00";
...@@ -264,7 +285,7 @@ Batch inserts data into the database. This API is called by the server and can b ...@@ -264,7 +285,7 @@ Batch inserts data into the database. This API is called by the server and can b
**Example** **Example**
```ts ```ts
import rdb from '@ohos.data.rdb'; import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db"; let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00"; 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. 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.
先完成此消息的编辑!
想要评论请 注册