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

!8391 翻译完成:8081 【轻量级 PR】:开发指南问题修改(3.1-release)

Merge pull request !8391 from wusongqing/TR8081
# Data Ability Development # Data Ability Development
## When to Use ## When to Use
A Data ability helps applications manage access to data stored by themselves and other applications. It also provides APIs for sharing data with other applications either on the same device or across devices. A Data ability helps applications manage access to data stored by themselves and other applications. It also provides APIs for sharing data with other applications either on the same device or across devices.
Data ability providers can customize data access-related APIs such as data inserting, deleting, updating, and querying, as well as file opening, and share data with other applications through these open APIs. Data ability providers can customize data access-related APIs such as data inserting, deleting, updating, and querying, as well as file opening, and share data with other applications through these open APIs.
## Available APIs ## Available APIs
**Table 1** Data ability lifecycle APIs **Table 1** Data ability lifecycle APIs
...@@ -18,7 +21,7 @@ Data ability providers can customize data access-related APIs such as data inser ...@@ -18,7 +21,7 @@ Data ability providers can customize data access-related APIs such as data inser
|denormalizeUri?(uri: string, callback: AsyncCallback\<string>): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| |denormalizeUri?(uri: string, callback: AsyncCallback\<string>): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.|
|insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\<number>): void|Inserts a data record into the database.| |insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\<number>): void|Inserts a data record into the database.|
|openFile?(uri: string, mode: string, callback: AsyncCallback\<number>): void|Opens a file.| |openFile?(uri: string, mode: string, callback: AsyncCallback\<number>): void|Opens a file.|
|getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\<Array\<string>>): void|Obtains the MIME type of a file.| |getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array\<string>>): void|Obtains the MIME type of a file.|
|getType?(uri: string, callback: AsyncCallback\<string>): void|Obtains the MIME type matching the data specified by the URI.| |getType?(uri: string, callback: AsyncCallback\<string>): void|Obtains the MIME type matching the data specified by the URI.|
|executeBatch?(ops: Array\<DataAbilityOperation>, callback: AsyncCallback\<Array\<DataAbilityResult>>): void|Operates data in the database in batches.| |executeBatch?(ops: Array\<DataAbilityOperation>, callback: AsyncCallback\<Array\<DataAbilityResult>>): void|Operates data in the database in batches.|
|call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\<PacMap>): void|Calls a custom API.| |call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\<PacMap>): void|Calls a custom API.|
...@@ -115,7 +118,7 @@ Import the basic dependency packages and obtain the URI string for communicating ...@@ -115,7 +118,7 @@ Import the basic dependency packages and obtain the URI string for communicating
The basic dependency packages include: The basic dependency packages include:
- @ohos.ability.featureAbility - @ohos.ability.featureAbility
- @ohos.data.dataability - @ohos.data.dataAbility
- @ohos.data.rdb - @ohos.data.rdb
#### Data Ability API Development #### Data Ability API Development
...@@ -129,7 +132,7 @@ The basic dependency packages include: ...@@ -129,7 +132,7 @@ The basic dependency packages include:
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataAbility' import ohos_data_ability from '@ohos.data.dataAbility'
import ohos_data_rdb from '@ohos.data.rdb' import ohos_data_rdb from '@ohos.data.rdb'
var urivar = "dataability:///com.ix.DataAbility" var urivar = "dataability:///com.ix.DataAbility"
var DAHelper = featureAbility.acquireDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
urivar urivar
......
...@@ -595,7 +595,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to ...@@ -595,7 +595,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | ID of the connection between the two abilities.| | number | Result code of the ability connection.|
**Example** **Example**
```js ```js
...@@ -606,7 +606,7 @@ var want = { ...@@ -606,7 +606,7 @@ var want = {
} }
var options = { var options = {
onConnect: (elementName, remote) => { onConnect: (elementName, remote) => {
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' remote) console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' + remote)
}, },
onDisconnect: (elementName) => { onDisconnect: (elementName) => {
console.log('connectAbility onDisconnect, elementName: ' + elementName) console.log('connectAbility onDisconnect, elementName: ' + elementName)
...@@ -615,8 +615,8 @@ var options = { ...@@ -615,8 +615,8 @@ var options = {
console.log('connectAbility onFailed, code: ' + code) console.log('connectAbility onFailed, code: ' + code)
} }
} }
this.context.connectAbility(want, options) { let result = this.context.connectAbility(want, options) {
console.log('code: ' + code) console.log('code: ' + result)
} }
``` ```
...@@ -652,7 +652,7 @@ var want = { ...@@ -652,7 +652,7 @@ var want = {
var accountId = 111; var accountId = 111;
var options = { var options = {
onConnect: (elementName, remote) => { onConnect: (elementName, remote) => {
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' remote) console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' + remote)
}, },
onDisconnect: (elementName) => { onDisconnect: (elementName) => {
console.log('connectAbility onDisconnect, elementName: ' + elementName) console.log('connectAbility onDisconnect, elementName: ' + elementName)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册