From 832b54f2f12d3ce6216a0a241623df812c01d33d Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Sat, 29 Jul 2023 18:08:37 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../apis/js-apis-data-preferences.md | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index e2a87d1165..85c0711fe6 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -40,7 +40,7 @@ Obtains a **Preferences** instance. This API uses an asynchronous callback to re | -------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | | name | string | Yes | Name of the **Preferences** instance. | -| callback | AsyncCallback<[Preferences](#preferences)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **object** is the **Preferences** instance obtained. Otherwise, **err** is an error code.| +| callback | AsyncCallback<[Preferences](#preferences)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and the **Preferences** instance obtained is returned. Otherwise, **err** is an error object.| **Example** @@ -163,7 +163,7 @@ class EntryAbility extends UIAbility { deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void -Deletes a **Preferences** instance from the memory. This API uses an asynchronous callback to return the result. +Deletes a **Preferences** instance from the cache. This API uses an asynchronous callback to return the result. If the **Preferences** instance has a persistent file, this API also deletes the persistent file. @@ -176,8 +176,8 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi | Name | Type | Mandatory| Description | | -------- | ------------------------------------- | ---- | ---------------------------------------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | -| name | string | Yes | Name of the **Preferences** instance to delete. | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +| name | string | Yes | Name of the **Preferences** instance. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Error codes** @@ -235,7 +235,7 @@ class EntryAbility extends UIAbility { deletePreferences(context: Context, name: string): Promise<void> -Deletes a **Preferences** instance from the memory. This API uses a promise to return the result. +Deletes a **Preferences** instance from the cache. This API uses a promise to return the result. If the **Preferences** instance has a persistent file, this API also deletes the persistent file. @@ -248,7 +248,7 @@ The deleted **Preferences** instance cannot be used for data operations. Otherwi | Name | Type | Mandatory| Description | | ------- | ------------------------------------- | ---- | ----------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | -| name | string | Yes | Name of the **Preferences** instance to delete.| +| name | string | Yes | Name of the **Preferences** instance.| **Return value** @@ -310,7 +310,7 @@ class EntryAbility extends UIAbility { removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<void>): void -Removes a **Preferences** instance from the memory. This API uses an asynchronous callback to return the result. +Removes a **Preferences** instance from the cache. This API uses an asynchronous callback to return the result. The removed **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will be caused. @@ -321,8 +321,8 @@ The removed **Preferences** instance cannot be used for data operations. Otherwi | Name | Type | Mandatory| Description | | -------- | ------------------------------------- | ---- | ---------------------------------------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | -| name | string | Yes | Name of the **Preferences** instance to remove. | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +| name | string | Yes | Name of the **Preferences** instance. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** @@ -373,7 +373,7 @@ class EntryAbility extends UIAbility { removePreferencesFromCache(context: Context, name: string): Promise<void> -Removes a **Preferences** instance from the memory. This API uses a promise to return the result. +Removes a **Preferences** instance from the cache. This API uses a promise to return the result. The removed **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will be caused. @@ -384,7 +384,7 @@ The removed **Preferences** instance cannot be used for data operations. Otherwi | Name | Type | Mandatory| Description | | ------- | ------------------------------------- | ---- | ----------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md). | -| name | string | Yes | Name of the **Preferences** instance to remove.| +| name | string | Yes | Name of the **Preferences** instance.| **Return value** @@ -455,7 +455,7 @@ Obtains the value of a key. This API uses an asynchronous callback to return the | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | key | string | Yes | Key of the data to obtain. It cannot be empty. | | defValue | [ValueType](#valuetype) | Yes | Default value to be returned. The value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.| -| callback | AsyncCallback<[ValueType](#valuetype)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is** undefined** and **data** is the value obtained. Otherwise, **err** is an error code.| +| callback | AsyncCallback<[ValueType](#valuetype)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the value obtained. Otherwise, **err** is an error object.| **Example** @@ -522,7 +522,7 @@ Obtains an **Object** instance that contains all KV pairs. This API uses an asyn | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<Object> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **value** is the **Object** instance obtained. Otherwise, **err** is an error code.| +| callback | AsyncCallback<Object> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **value** is the **Object** instance obtained. Otherwise, **err** is an error object.| **Example** @@ -538,7 +538,7 @@ try { console.info("getAll object = " + JSON.stringify(value)); }) } catch (err) { - console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); + console.info("Failed to obtain all KV pairs. code =" + err.code + ", message =" + err.message); } ``` @@ -567,10 +567,10 @@ try { console.info('getAll keys = ' + allKeys); console.info("getAll object = " + JSON.stringify(value)); }).catch((err) => { - console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); + console.info("Failed to obtain all KV pairs. code =" + err.code + ", message =" + err.message); }) } catch (err) { - console.info("Failed to get all KV pairs. code =" + err.code + ", message =" + err.message); + console.info("Failed to obtain all KV pairs. code =" + err.code + ", message =" + err.message); } ``` @@ -578,7 +578,7 @@ try { put(key: string, value: ValueType, callback: AsyncCallback<void>): void -Writes data to this **Preferences** instance. This API uses an asynchronous callback to return the result. You can use [flush](#flush) to make the **Preferences** instance persistent. +Writes data to this **Preferences** instance. This API uses an asynchronous callback to return the result. You can use [flush](#flush) to persist the **Preferences** instance. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -588,7 +588,7 @@ Writes data to this **Preferences** instance. This API uses an asynchronous call | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | key | string | Yes | Key of the data. It cannot be empty. | | value | [ValueType](#valuetype) | Yes | Value to write. The value can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.| -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is undefined. Otherwise, **err** is an error code. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If data is written successfully, **err** is **undefined**. Otherwise, **err** is an error object. | **Example** @@ -611,7 +611,7 @@ try { put(key: string, value: ValueType): Promise<void> -Writes data to this **Preferences** instance. This API uses a promise to return the result. You can use [flush](#flush) to make the **Preferences** instance persistent. +Writes data to this **Preferences** instance. This API uses a promise to return the result. You can use [flush](#flush) to persist the **Preferences** instance. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -733,7 +733,7 @@ Deletes a KV pair from this **Preferences** instance based on the specified key. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------------------------------------- | | key | string | Yes | Key of the KV pair to delete. It cannot be empty. | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** @@ -756,7 +756,7 @@ try { delete(key: string): Promise<void> -Deletes a KV pair from this **Preferences** instance. This API uses a promise to return the result. +Deletes a KV pair from this **Preferences** instance based on the specified key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -800,7 +800,7 @@ Saves the data of this **Preferences** instance to a file asynchronously. This A | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------------------------------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** @@ -861,7 +861,7 @@ Clears this **Preferences** instance. This API uses an asynchronous callback to | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------------------------------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error code.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| **Example** @@ -972,7 +972,7 @@ Unsubscribes from data changes. | Name | Type | Mandatory| Description | | -------- | -------------------------------- | ---- | ------------------------------------------ | -| type | string | Yes | Event type to unsubscribe from. The value **change** indicates data change events. | +| type | string | Yes | Event type to unsubscribe from. The value **change** indicates data change events. | | callback | Callback<{ key : string }> | No | Callback to unregister. If this parameter is left blank, the callbacks for all data changes will be unregistered.| **Example** @@ -993,7 +993,7 @@ try { console.info("Failed to put the value of 'startup'. Cause: " + err); return; } - console.info("Put the value of 'startup' successfully."); + console.info("Successfully put the value of 'startup'."); preferences.flush(function (err) { if (err) { @@ -1023,4 +1023,4 @@ Enumerates the value types. | boolean | The value is of Boolean type. | | Array\ | The value is an array of numbers. | | Array\ | The value is a Boolean array. | -| Array\ | The value is an array of the strings.| +| Array\ | The value is an array of strings.| -- GitLab