提交 c73982dd 编写于 作者: A Annie_wang
上级 a19ca4d6
...@@ -16,7 +16,7 @@ This module provides the following common functions: ...@@ -16,7 +16,7 @@ This module provides the following common functions:
import cloudData from '@ohos.data.cloudData'; import cloudData from '@ohos.data.cloudData';
``` ```
## Action ## ClearAction
Enumerates the actions to take to clear the downloaded cloud data locally. Enumerates the actions to take to clear the downloaded cloud data locally.
...@@ -347,9 +347,9 @@ try { ...@@ -347,9 +347,9 @@ try {
} }
``` ```
### clean ### clear
static clean(accountId: string, appActions: {[bundleName: string]: Action}, callback: AsyncCallback<void>):void static clear(accountId: string, appActions: {[bundleName: string]: ClearAction}, callback: AsyncCallback<void>):void
Clears the cloud data locally. This API uses an asynchronous callback to return the result. Clears the cloud data locally. This API uses an asynchronous callback to return the result.
...@@ -361,26 +361,26 @@ Clears the cloud data locally. This API uses an asynchronous callback to return ...@@ -361,26 +361,26 @@ Clears the cloud data locally. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ----------------------------------------- | ---- | -------------------------------- | | ---------- | --------------------------------------------------- | ---- | -------------------------------- |
| accountId | string | Yes | ID of the cloud account. | | accountId | string | Yes | ID of the cloud account. |
| appActions | {[bundleName: string]: [Action](#action)} | Yes | Information about the application whose data is to be cleared and the action to take.| | appActions | {[bundleName: string]: [ClearAction](#clearaction)} | Yes | Information about the application whose data is to be cleared and the action to take.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example** **Example**
```js ```js
let action = cloudData.Action; let action = cloudData.ClearAction;
let account = "test_id"; let account = "test_id";
let bundleName1 = "test_bundleName1"; let bundleName1 = "test_bundleName1";
let bundleName2 = "test_bundleName2"; let bundleName2 = "test_bundleName2";
let appActions = { [bundleName1]: action.CLEAR_CLOUD_INFO, [bundleName2]: action.CLEAR_CLOUD_DATA_AND_INFO }; let appActions = { [bundleName1]: action.CLEAR_CLOUD_INFO, [bundleName2]: action.CLEAR_CLOUD_DATA_AND_INFO };
try { try {
cloudData.Config.clean(account, appActions, function (err) { cloudData.Config.clear(account, appActions, function (err) {
if (err === undefined) { if (err === undefined) {
console.info('Succeeding in cleaning cloud data'); console.info('Succeeding in clearing cloud data');
} else { } else {
console.error(`Failed to clean cloud data. Code: ${err.code}, message: ${err.message}`); console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
} }
}); });
} catch (error) { } catch (error) {
...@@ -388,9 +388,9 @@ try { ...@@ -388,9 +388,9 @@ try {
} }
``` ```
### clean ### clear
static clean(accountId: string, appActions: {[bundleName: string]: Action}): Promise<void> static clear(accountId: string, appActions: {[bundleName: string]: ClearAction}): Promise<void>
Clears the cloud data locally. This API uses a promise to return the result. Clears the cloud data locally. This API uses a promise to return the result.
...@@ -402,10 +402,10 @@ Clears the cloud data locally. This API uses a promise to return the result. ...@@ -402,10 +402,10 @@ Clears the cloud data locally. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ----------------------------------------- | ---- | -------------------------------- | | ---------- | --------------------------------------------------- | ---- | -------------------------------- |
| accountId | string | Yes | ID of the cloud account. | | accountId | string | Yes | ID of the cloud account. |
| appActions | {[bundleName: string]: [Action](#action)} | Yes | Information about the application whose data is to be cleared and the action to take.| | appActions | {[bundleName: string]: [ClearAction](#clearaction)} | Yes | Information about the application whose data is to be cleared and the action to take.|
**Return value** **Return value**
...@@ -416,16 +416,16 @@ Clears the cloud data locally. This API uses a promise to return the result. ...@@ -416,16 +416,16 @@ Clears the cloud data locally. This API uses a promise to return the result.
**Example** **Example**
```js ```js
let action = cloudData.Action; let action = cloudData.ClearAction;
let account = "test_id"; let account = "test_id";
let bundleName1 = "test_bundleName1"; let bundleName1 = "test_bundleName1";
let bundleName2 = "test_bundleName2"; let bundleName2 = "test_bundleName2";
let appActions = { [bundleName1]: action.CLEAR_CLOUD_INFO, [bundleName2]: action.CLEAR_CLOUD_DATA_AND_INFO }; let appActions = { [bundleName1]: action.CLEAR_CLOUD_INFO, [bundleName2]: action.CLEAR_CLOUD_DATA_AND_INFO };
try { try {
cloudData.Config.clean(account, appActions).then(() => { cloudData.Config.clear(account, appActions).then(() => {
console.info('Succeeding in cleaning cloud data'); console.info('Succeeding in clearing cloud data');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to clean cloud data. Code: ${err.code}, message: ${err.message}`); console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
}); });
} catch (error) { } catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册