提交 d3ec5725 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 a999e60e
......@@ -40,7 +40,7 @@ There are two roles in **DataShare**:
- **onCreate**
Called by the server to initialize service logic when the **DataShare** client connects to the **DataShareExtensionAbility** server. This method can be overridden as required.
Called by the server to initialize service logic when the **DataShare** client connects to the **DataShareExtensionAbility** server.
- **insert**
......@@ -76,10 +76,7 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt
2. Right-click the **DataShareAbility** directory, and choose **New > TypeScript File** to create a file named **DataShareAbility.ts**.
3. In the **DataShareAbility.ts** file, import the **DataShareExtensionAbility** dependency package. You can override the service implementation as required. For example, if the data provider provides only the services for inserting, deleting, and querying data, you can override **insert()**, **delete()**, and **query()** only.
4. Import dependencies.
3. In the **DataShareAbility.ts** file, import **DataShareExtensionAbility** and other dependencies.
```ts
import Extension from '@ohos.application.DataShareExtensionAbility';
......@@ -88,9 +85,9 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
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
const DB_NAME = "DB00.db";
......@@ -146,14 +143,15 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt
};
```
7. Define **DataShareExtensionAbility** in **module.json5**.
| Field| Description |
| ------------ | ------------------------------------------------------------ |
6. Define **DataShareExtensionAbility** in **module.json5**.
| Field | Description |
| --------- | ------------------------------------------------------------ |
| "name" | Ability name, corresponding to the **ExtensionAbility** class name derived from **Ability**. |
| "type" | Ability type. The value is **dataShare**, indicating the development is based on the **datashare** template.|
| "type" | Ability type. The value is **dataShare**, indicating the development is based on the **datashare** template. |
| "uri" | URI used for communication. It is the unique identifier for the data consumer to connect to the provider. |
| "visible" | Whether it is visible to other applications. Data sharing is allowed only when the value is **true**.|
| "visible" | Whether it is visible to other applications. Data sharing is allowed only when the value is **true**. |
**module.json5 example**
......@@ -171,6 +169,8 @@ Before implementing a **DataShare** service, you need to create a **DataShareExt
]
```
### Data Consumer Application Development
1. Import dependencies.
......
......@@ -119,7 +119,7 @@ The following uses a single KV store as an example to describe the development p
}
distributedKVStore.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.error(`Failed to createKVManager.code is ${err.code},message is ${err.message}`);
console.error(`Failed to create KVManager. code is ${err.code},message is ${err.message}`);
return;
}
console.log('Created KVManager successfully');
......
......@@ -200,6 +200,6 @@ You can use the following APIs to delete a **Preferences** instance or data file
proDelete.then(() => {
console.info("Deleted data successfully.");
}).catch((err) => {
console.info("Failed to delete. Cause: " + err);
console.info("Failed to delete data. Cause: " + err);
})
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册