From 38cf90881090c9cef90f3f2e93174bca14b74612 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 5 May 2022 16:40:55 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-volumemanager.md | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-volumemanager.md diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md new file mode 100644 index 0000000000..e4e44b0db4 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-volumemanager.md @@ -0,0 +1,179 @@ +# Volume Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> +> - The initial APIs of this module are supported since API version 9. 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. + +## Modules to Import + +```js +import volumemanager from "@ohos.volumeManager"; +``` + +## volumemanager.getAllVolumes + +getAllVolumes(): Promise<Array<Volume>> + +Asynchronously obtains information about all available volumes. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Return value + + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | Promise used to return the execution result.| + +- Example + + ```js + volumemanager.getAllVolumes().then(function(volumes){ + // do something + }); + ``` + +## volumemanager.getAllVolumes + +getAllVolumes(callback: AsyncCallback<Array<Volume>>): void + +Asynchronously obtains information about all available volumes. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return the volume information obtained.| + +- Example + + ```js + let uuid = ""; + volumemanager.getAllVolumes(uuid, function(error, volumes){ + // do something + }); + ``` + + +## volumemanager.mount + +mount(volumeId: string): Promise<boolean> + +Asynchronously mounts a volume. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Parameters + + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| + +- Return value + + | Type | Description | + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.mount + +mount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId, function(error, flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string): Promise<boolean> + +Asynchronously unmounts a volume. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Parameters + + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| + +- Return value + + | Type | Description | + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously unmounts a volume. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | callback:AsyncCallback<boolean> | Yes | Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId, function(error, flag){ + // do something + }); + ``` + +## Volume + +**System capability**: SystemCapability.FileManagement.StorageService.Volume + +### Attributes + +| Name | Type | Description | +| ----------- | ------- | -------------------- | +| id | number | Volume ID. | +| uuid | string | Universally unique identifier (UUID) of the volume. | +| description | string | Description of the volume. | +| removable | boolean | Whether the volume is a removable storage device.| +| state | int | Current volume status. | +| path | string | Mount address of the volume. | -- GitLab