From 81237f34d512374ed8e04db0850964f73b7717f8 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Mon, 9 May 2022 17:01:03 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-filemanager.md | 76 +++++++++---------- .../reference/apis/js-apis-system-storage.md | 52 ++++++------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-filemanager.md b/en/application-dev/reference/apis/js-apis-filemanager.md index a100d8b027..b7e33e70ef 100644 --- a/en/application-dev/reference/apis/js-apis-filemanager.md +++ b/en/application-dev/reference/apis/js-apis-filemanager.md @@ -1,5 +1,5 @@ -# Public File Access and Management ->![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +# User File Access and Management +>![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> >- The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. >- The APIs of this module are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**. @@ -14,20 +14,20 @@ import filemanager from '@ohos.fileManager'; getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> -Obtains information about the files in the first-level directory in asynchronous mode. This method uses a promise to return the result. +Obtains information about the root album or directory in asynchronous mode. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService - Parameters | Name| Type| Mandatory| Description| | --- | --- | --- | -- | - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| - Return value | Type| Description| | --- | -- | - | Promise<[FileInfo](#fileinfo)[]> | Promise used to return the file information obtained.| + | Promise<[FileInfo](#fileinfo)[]> | Promise used to return the root album or directory information obtained.| - Example @@ -35,7 +35,7 @@ Obtains information about the files in the first-level directory in asynchronous filemanager.getRoot().then((fileInfo) => { if(Array.isArray(fileInfo)) { for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) + console.log("file:"+JSON.stringify(fileInfo)); } } }).catch((err) => { @@ -47,7 +47,7 @@ Obtains information about the files in the first-level directory in asynchronous getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>) : void -Obtains information about the files in the first-level directory in asynchronous mode. This method uses a callback to return the result. +Obtains information about the root album or directory in asynchronous mode. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService @@ -55,8 +55,8 @@ Obtains information about the files in the first-level directory in asynchronous | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ----------------------------- | - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| - | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. | + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| + | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the root album or directory information obtained. | - Example @@ -64,7 +64,7 @@ Obtains information about the files in the first-level directory in asynchronous filemanager.getRoot((err, fileInfo) => { if(Array.isArray(fileInfo)) { for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) + console.log("file:"+JSON.stringify(fileInfo)); } } }); @@ -74,7 +74,7 @@ Obtains information about the files in the first-level directory in asynchronous listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise<FileInfo[]> -Obtains information about the files in the second-level directory in asynchronous mode. This method uses a promise to return the result. +Obtains information about the second-level album or files in asynchronous mode. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService @@ -83,32 +83,32 @@ Obtains information about the files in the second-level directory in asynchronou | --- | --- | --- | -- | | path | string | Yes| URI of the directory to query.| | type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.| - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.
-  **offset**: position to start the query. The value is a number.
-  **count**: number of files to query.| + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.
-  **offset**: position to start the query. The value is a number.
-  **count**: number of files to query.| - Return value | Type| Description| | --- | -- | - | Promise<FileInfo[]> | Promise used to return the file information obtained.| + | Promise<FileInfo[]> | Promise used to return the album or file information obtained.| - Error | Error Info| Error Code|Description| | -- | --- | -- | - | No such file or directory | 2 | The directory or file of the specified URI does not exist.| + | No such file or directory | 2 | The directory or album of the specified URI does not exist.| | No such process | 3 | Failed to obtain the FMS service.| - | Not a directory | 20 | The object specified by the URI is not a directory.| + | Not a directory | 20 | The object specified by the URI is not a directory or album.| - Example ```js // Obtain all files in the directory. - // Call listFile() and getRoot() to obtain file URIs. + // Call listFile() and getRoot() to obtain the file URI. let media_path = file.uri filemanager.listFile(media_path, "file") .then((fileInfo) => { if(Array.isArray(fileInfo)) { for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) + console.log("file:"+JSON.stringify(fileInfo)); } } }).catch((err) => { @@ -120,7 +120,7 @@ Obtains information about the files in the second-level directory in asynchronou listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback<FileInfo[]>) : void -Obtains information about the files in the second-level directory in asynchronous mode. This method uses a callback to return the result. +Obtains information about the second-level album or files in asynchronous mode. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService @@ -130,25 +130,25 @@ Obtains information about the files in the second-level directory in asynchronou | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | URI of the directory to query. | | type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.| - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.
-  **offset**: position to start the query. The value is a number.
-  **count**: number of files to query.| + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.
-  **offset**: position to start the query. The value is a number.
-  **count**: number of files to query.| | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. | - Error | Error Info | Error Code| Description | | ------------------------- | ------ | ------------------------- | - | No such file or directory | 2 | The directory or file of the specified URI does not exist.| + | No such file or directory | 2 | The directory or album of the specified URI does not exist.| | No such process | 3 | Failed to obtain the FMS service. | - | Not a directory | 20 | The object specified by the URI is not a directory.| + | Not a directory | 20 | The object specified by the URI is not a directory or album.| - Example ```js - // Call listFile() and getRoot() to obtain file URIs. + // Call listFile() and getRoot() to obtain the file URI. let media_path = file.uri filemanager.listFile(media_path, "file", (err, fileInfo) => { if(Array.isArray(fileInfo)) { for (var i = 0; i < fileInfo.length; i++) { - console.log(JSON.Stringify(fileInfo)) + console.log("file:"+JSON.stringify(fileInfo)); } } }); @@ -158,7 +158,7 @@ Obtains information about the files in the second-level directory in asynchronou filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise<string> -Creates a file in the specified path in asynchronous mode. This method uses a promise to return the result. +Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService @@ -167,7 +167,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr | --- | --- | --- | -- | | filename | string | Yes| Name of the file to create.| | path | string | Yes| URI of the file to create.| - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| - Return value @@ -179,9 +179,9 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr | Error Info| Error Code|Description| | -- | --- | -- | | Operation not permitted | 1 | A file with the same name already exists.| - | No such file or directory | 2 | The directory or file of the specified URI does not exist.| + | No such file or directory | 2 | The directory or album of the specified URI does not exist.| | No such process | 3 | Failed to obtain the FMS service.| - | Not a directory | 20 | The object specified by the URI is not a directory.| + | Not a directory | 20 | The object specified by the URI is not a directory or album.| - Example @@ -189,12 +189,11 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr // Create a file. let media_path = file.uri // Obtain the file URI using listFile() and getRoot(). let name = "xxx.jpg" // File to be saved. - filemanager.createFile(media_path, name) - .then((uri) => { - // The URI of the file created is returned. - }) - .catch((err) => { - console.log(err) + filemanager.createFile(media_path, name).then((uri) => { + // The URI of the file created is returned. + console.log("file uri:"+uri); + }).catch((err) => { + console.log(err); }); ``` @@ -202,7 +201,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr createFile(path : string, filename: string, options? : {dev? : DevInfo}, callback : AsyncCallback<string>) : void -Creates a file in the specified path in asynchronous mode. This method uses a callback to return the result. +Creates a file in the specified path in asynchronous mode. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.FileManagerService @@ -212,7 +211,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca | -------- | ------------------------- | ---- | ----------------------------- | | filename | string | Yes | Name of the file to create. | | path | string | Yes | URI of the file to create. | - | options | Object | No| The options are as follows:
-  **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| + | options | Object | No| The options are as follows:
-  **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. | - Error @@ -220,9 +219,9 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca | Error Info | Error Code| Description | | ------------------------- | ------ | ------------------------- | | Operation not permitted | 1 | A file with the same name already exists. | - | No such file or directory | 2 | The directory or file of the specified URI does not exist.| + | No such file or directory | 2 | The directory or album of the specified URI does not exist.| | No such process | 3 | Failed to obtain the FMS service. | - | Not a directory | 20 | The object specified by the URI is not a directory.| + | Not a directory | 20 | The object specified by the URI is not a directory or album.| - Example @@ -233,7 +232,8 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca // File to be saved. let name = "xxx.jpg" filemanager.createFile(media_path, name, (err, uri) => { - // The URI of the file created is returned. + // The URI of the file created is returned. + console.log("file uri:"+uri); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-system-storage.md b/en/application-dev/reference/apis/js-apis-system-storage.md index 79c841adb6..d80bf1ea12 100644 --- a/en/application-dev/reference/apis/js-apis-system-storage.md +++ b/en/application-dev/reference/apis/js-apis-system-storage.md @@ -2,7 +2,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> -> - The APIs of this module are no longer maintained since API Version 6. You are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). +> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). > > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,7 +10,7 @@ ## Modules to Import -``` +```js import storage from '@system.storage'; ``` @@ -19,7 +19,7 @@ import storage from '@system.storage'; get(Object): void -Obtains the stored data. +Reads the value stored in the cache based on the specified key. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -27,15 +27,15 @@ Obtains the stored data. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| key | string | Yes| Index of the data to obtain.| +| key | string | Yes| Key of the data to read.| | default | string | No| Default value returned when the **key** does not exist.| -| success | Function | No| Called when the stored data is successfully obtained.| -| fail | Function | No| Called when the stored data failed to be obtained.| -| complete | Function | No| Called when the execution is complete.| +| success | Function | No| Called to return the value obtained when **storage.get()** is successful.| +| fail | Function | No| Called when **storage.get()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| +| complete | Function | No| Called when **storage.get()** is complete.| **Example** -``` +```js export default { storageGet() { storage.get({ @@ -59,7 +59,7 @@ export default { set(Object): void -Modifies the stored data. +Sets the value in the cache based on the specified key. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -67,15 +67,15 @@ Modifies the stored data. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| key | string | Yes| Index of the data to modify.| -| value | string | No| New value to set. The maximum length is 128 bytes.| -| success | Function | No| Called when the data is successfully modified.| -| fail | Function | No| Called when the data failed to be modified.| -| complete | Function | No| Called when the execution is complete.| +| key | string | Yes| Key of the value to set.| +| value | string | Yes| New value to set. The maximum length is 128 bytes.| +| success | Function | No| Called when **storage.set()** is successful.| +| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| +| complete | Function | No| Called when **storage.set()** is complete.| **Example** -``` +```js export default { storageSet() { storage.set({ @@ -97,7 +97,7 @@ export default { clear(Object): void -Clears the stored data. +Clears the key-value pairs from the cache. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -105,13 +105,13 @@ Clears the stored data. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| success | Function | No| Called when the data is successfully cleared.| -| fail | Function | No| Called when the data failed to be cleared.| -| complete | Function | No| Called when the execution is complete.| +| success | Function | No| Called when **storage.clear()** is successful.| +| fail | Function | No| Called when **storage.clear()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| +| complete | Function | No| Called when **storage.clear()** is complete.| **Example** -``` +```js export default { storageClear() { storage.clear({ @@ -131,7 +131,7 @@ export default { delete(Object): void -Deletes the stored data. +Deletes the key-value pair based on the specified key. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -139,14 +139,14 @@ Deletes the stored data. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| key | string | Yes| Index of the data to delete.| -| success | Function | No| Called when the data is deleted.| -| fail | Function | No| Called when the data failed to be deleted.| -| complete | Function | No| Called when the execution is complete.| +| key | string | Yes| Key of the data to delete.| +| success | Function | No| Called when **storage.delete()** is successful.| +| fail | Function | No| Called when **storage.delete()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| +| complete | Function | No| Called when **storage.delete()** is complete.| **Example** -``` +```js export default { storageDelete() { storage.delete({ -- GitLab