5. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only **query()**.
4. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only **query()**.
6. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network.
5. Implement the data provider services. For example, implement data storage of the data provider by using a database, reading and writing files, or accessing the network.
```ts
constDB_NAME="DB00.db";
...
...
@@ -95,13 +95,13 @@ Before implementing a **DataShare** service, create a **DataShareExtensionAbilit
constDDL_TBL_CREATE="CREATE TABLE IF NOT EXISTS "
+TBL_NAME
+" (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)";
| "name" | Ability name, corresponding to the **ExtensionAbility** class name derived from **Ability**. | Yes |
| "type" | Ability type. The value is **dataShare**, indicating the development is based on the **datashare** template. | Yes |
| "uri" | URI used for communication. It is the unique identifier for the data consumer to connect to the provider. | Yes |
| "visible" | Whether it is visible to other applications. Data sharing is allowed only when the value is **true**. | Yes |
| "metadata" | Configuration for silent access, including the **name** and **resource** fields. <br/>The **name** field identifies the configuration, which has a fixed value of **ohos.extension.dataShare**. <br/>The **resource** field has a fixed value of **$profile:data_share_config**, which indicates that the profile name is **data_share_config.json**. | **metadata** is mandatory when the ability launch type is **singleton**. For details about the ability launch type, see **launchType** in the [Internal Structure of the abilities Attribute](../quick-start/module-structure.md#internal-structure-of-the-abilities-attribute). |
**module.json5 example**
```json
"extensionAbilities":[
{
...
...
@@ -163,10 +164,44 @@ Before implementing a **DataShare** service, create a **DataShareExtensionAbilit
| "uri" | Range for which the configuration takes effect. The URI supports the following formats in descending order by priority: - *****: indicates all databases and tables. - **datashare:///{\*bundleName\*}/{\*moduleName\*}/{\*storeName\*}**: specifies a database. - **datashare:///{\*bundleName\*}/{\*moduleName\*}/{\*storeName\*}/{\*tableName\*}** : specifies a table. If URIs of different formats are configured, only the URI with higher priority takes effect. | Yes |
| "crossUserMode" | Whether data is shared by multiple users. The value **1** means to share data between multiple users, and the value **2** means the opposite. | **crossUserMode** is mandatory when the ability launch type is **singleton**. For details about the ability launch type, see **launchType** in the [Internal Structure of the abilities Attribute](../quick-start/module-structure.md#internal-structure-of-the-abilities-attribute). |
| "writePermission" | Write permission required for silent access. | No |
| "readPermission" | Read permission required for silent access. | No |
@@ -182,7 +217,7 @@ Before implementing a **DataShare** service, create a **DataShareExtensionAbilit
```ts
// Different from the URI defined in the module.json5 file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).