• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# DataAbility Component Configuration
2<!--Kit: Ability Kit-->
3<!--Subsystem: Ability-->
4<!--Owner: @xialiangwei-->
5<!--Designer: @jsjzju-->
6<!--Tester: @lixueqing513-->
7<!--Adviser: @huipeizi-->
8
9
10## URI Introduction
11
12A Uniform Resource Identifier (URI) is used to identify a specific data item, such as a table in the database or a file on the disk. URIs used comply with the commonly used URI standard. A URI consists of the components:
13
14![fa-dataability-uri](figures/fa-dataability-uri.png)
15
16- **scheme**: name of the scheme used by the DataAbility. The value is fixed at **dataability**.
17
18- **authority**: device ID. To access data on a remote device, set this component to the ID of the remote device. To access data on the local device, leave this component empty.
19
20- **path**: location of the specific resource to access.
21
22- **query**: query parameters.
23
24- **fragment**: subordinate resources to access.
25
26Example URIs:
27
28- Cross-device scenario: dataability://_device_id_/_com.domainname.dataability.persondata_/_person_/_10_
29
30- Local device scenario: dataability:///_com.domainname.dataability.persondata_/_person_/_1_
31
32> **NOTE**
33>
34> In the case of local-device communication, **device_id** is empty, and therefore, there are three slashes (/) after **dataability:**.
35
36
37## Introduction to Certain Configuration Items
38
39Similar to a PageAbility, a DataAbility is configured in **abilities** under **module** of the **config.json** file. The difference between a DataAbility and PageAbility lies in the **type** and **uri** fields.
40
41**Table 1** DataAbility configuration items
42
43| Name| Description|
44| -------- | -------- |
45| "name" | Ability name.|
46| "type" | Type of the ability. The value **data** indicates a DataAbility.|
47| "uri" | URI used for communication.|
48| "visible" | Whether the ability is visible to other applications. Data sharing is allowed only when the value is **true**.|
49
50The following is an example **config.json** file:
51
52
53```json
54"abilities": [
55  ...
56  {
57    "name": ".DataAbility",
58    "srcLanguage": "ets",
59    "srcPath": "DataAbility",
60    "icon": "$media:icon",
61    "description": "$string:DataAbility_desc",
62    "type": "data",
63    "visible": true,
64    "uri": "dataability://com.samples.famodelabilitydevelop.DataAbility",
65    "readPermission": "ohos.permission.READ_CONTACTS",
66    "writePermission": "ohos.permission.WRITE_CONTACTS"
67  },
68  ...
69]
70```
71
72For details about the configuration items, see [Internal Structure of module](../quick-start/module-structure.md).
73