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

!17981 [翻译完成】PR17295

Merge pull request !17981 from Annie_wang/PR17295
...@@ -32,7 +32,9 @@ The following table lists the APIs used for KV data persistence. Most of the API ...@@ -32,7 +32,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
## How to Develop ## How to Develop
1. Create a **KvManager** instance to manage database objects. Example: 1. Create a **KvManager** instance to manage database objects.
Example:
Stage model: Stage model:
...@@ -90,7 +92,9 @@ The following table lists the APIs used for KV data persistence. Most of the API ...@@ -90,7 +92,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
} }
``` ```
2. Create and obtain a KV store. Example: 2. Create and obtain a KV store.
Example:
```js ```js
try { try {
...@@ -116,7 +120,9 @@ The following table lists the APIs used for KV data persistence. Most of the API ...@@ -116,7 +120,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
} }
``` ```
3. Use **put()** to add data to the KV store. Example: 3. Use **put()** to add data to the KV store.
Example:
```js ```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
...@@ -138,7 +144,9 @@ The following table lists the APIs used for KV data persistence. Most of the API ...@@ -138,7 +144,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
> >
> The **put()** method adds a KV pair if the specified key does not exists and changes the value if the the specified key already exists. > The **put()** method adds a KV pair if the specified key does not exists and changes the value if the the specified key already exists.
4. Use **get()** to obtain the value of a key. Example: 4. Use **get()** to obtain the value of a key.
Example:
```js ```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
...@@ -163,7 +171,9 @@ The following table lists the APIs used for KV data persistence. Most of the API ...@@ -163,7 +171,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
} }
``` ```
5. Use **delete()** to delete the data of the specified key. Example: 5. Use **delete()** to delete the data of the specified key.
Example:
```js ```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const KEY_TEST_STRING_ELEMENT = 'key_test_string';
......
...@@ -28,7 +28,7 @@ User applications call **Preference** through the JS interface to read and write ...@@ -28,7 +28,7 @@ User applications call **Preference** through the JS interface to read and write
The following table lists the APIs used for preferences data persistence. Most of the APIs are executed asynchronously, using a callback or promise to return the result. The following table uses the callback-based APIs as an example. For more information about the APIs, see [User Preferences](../reference/apis/js-apis-data-preferences.md). The following table lists the APIs used for preferences data persistence. Most of the APIs are executed asynchronously, using a callback or promise to return the result. The following table uses the callback-based APIs as an example. For more information about the APIs, see [User Preferences](../reference/apis/js-apis-data-preferences.md).
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void | Obtain a **Preferences** instance.| | getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void | Obtain a **Preferences** instance.|
| put(key: string, value: ValueType, callback: AsyncCallback<void>): void | Writes data to the Preferences instance. You can use **flush()** to persist the **Preferences** instance data.| | put(key: string, value: ValueType, callback: AsyncCallback<void>): void | Writes data to the Preferences instance. You can use **flush()** to persist the **Preferences** instance data.|
...@@ -157,7 +157,7 @@ The following table lists the APIs used for preferences data persistence. Most o ...@@ -157,7 +157,7 @@ The following table lists the APIs used for preferences data persistence. Most o
} }
``` ```
5. Deletes data. 5. Delete data.
Use delete() to delete a KV pair.<br>Example: Use delete() to delete a KV pair.<br>Example:
......
...@@ -142,7 +142,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP ...@@ -142,7 +142,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
3. Modify or delete data based on the specified **Predicates** instance. 3. Modify or delete data based on the specified **Predicates** instance.
Use **update()** to modify data and **delete()** to delete data. Example: Use **update()** to modify data and **delete()** to delete data.
Example:
```js ```js
// Modify data. // Modify data.
...@@ -176,7 +178,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP ...@@ -176,7 +178,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
4. Query data based on the conditions specified by **Predicates**. 4. Query data based on the conditions specified by **Predicates**.
Use **query()** to query data. The data obtained is returned in a **ResultSet** object. Example: Use **query()** to query data. The data obtained is returned in a **ResultSet** object.
Example:
```js ```js
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
...@@ -197,7 +201,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP ...@@ -197,7 +201,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
5. Delete the RDB store. 5. Delete the RDB store.
Use **deleteRdbStore()** to delete the RDB store and related database files. Example: Use **deleteRdbStore()** to delete the RDB store and related database files.
Example:
Stage model: Stage model:
...@@ -215,7 +221,7 @@ The following table lists the APIs used for RDB data persistence. Most of the AP ...@@ -215,7 +221,7 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
console.info('Succeeded in deleting RdbStore.'); console.info('Succeeded in deleting RdbStore.');
}); });
} }
} }
``` ```
FA model: FA model:
......
...@@ -91,7 +91,7 @@ The following table lists the APIs for cross-device data synchronization of the ...@@ -91,7 +91,7 @@ The following table lists the APIs for cross-device data synchronization of the
## How to Develop ## How to Develop
The following uses a single KV store as an example to describe how to implement cross-device data synchronization. The following describes the development process. The following uses a single KV store as an example to describe how to implement cross-device data synchronization. The development process is as follows.
![kvStore_development_process](figures/kvStore_development_process.png) ![kvStore_development_process](figures/kvStore_development_process.png)
......
...@@ -17,6 +17,7 @@ There are two roles in **DataShare**: ...@@ -17,6 +17,7 @@ There are two roles in **DataShare**:
- Data consumer: accesses the data provided by the provider using [createDataShareHelper()](../reference/apis/js-apis-data-dataShare.md#datasharecreatedatasharehelper). - Data consumer: accesses the data provided by the provider using [createDataShareHelper()](../reference/apis/js-apis-data-dataShare.md#datasharecreatedatasharehelper).
**Figure 1** Data sharing mechanism **Figure 1** Data sharing mechanism
![dataShare](figures/dataShare.jpg) ![dataShare](figures/dataShare.jpg)
- The **DataShareExtensionAbility** module, as the data provider, implements services related to data sharing between applications. - The **DataShareExtensionAbility** module, as the data provider, implements services related to data sharing between applications.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册