卷管理
卷管理
说明:
- 本模块首批接口从API version 9开始支持。
- API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
导入模块
import volumemanager from "@ohos.volumeManager";
volumemanager.getAllVolumes
getAllVolumes(): Promise<Array<Volume>>
异步获取当前所有可获得的卷信息,以promise方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
返回值
类型 说明 Promise<Volume[]> 返回当前所有可获得的卷信息 示例
volumemanager.getAllVolumes().then(function(volumes){ // do something });
1
2
3
volumemanager.getAllVolumes
getAllVolumes(callback: AsyncCallback<Array<Volume>>): void
异步获取当前所有可获得的卷信息,以callback方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
参数
参数名 类型 必填 说明 callback callback:AsyncCallback<Volume[]> 是 获取当前所有可获得的卷信息之后的回调 示例
let uuid = ""; volumemanager.getAllVolumes(uuid, function(error, volumes){ // do something });
1
2
3
4
volumemanager.mount
mount(volumeId: string): Promise<boolean>
异步挂载指定卷,以promise方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
参数
参数名 类型 必填 说明 volumeId string 是 卷id 返回值
类型 说明 Promise<boolean> 挂载指定卷 示例
let volumeId = ""; volumemanager.mount(volumeId).then(function(flag){ // do something });
1
2
3
4
volumemanager.mount
mount(volumeId: string, callback:AsyncCallback<boolean>):void
异步获取指定卷的可用空间大小,以callback方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
参数
参数名 类型 必填 说明 volumeId string 是 卷id callback callback:AsyncCallback<boolean> 是 挂载指定卷之后的回调 示例
let volumeId = ""; volumemanager.mount(volumeId, function(error, flag){ // do something });
1
2
3
4
volumemanager.unmount
unmount(volumeId: string): Promise<boolean>
异步卸载指定卷,以promise方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
参数
参数名 类型 必填 说明 volumeId string 是 卷id 返回值
类型 说明 Promise<boolean> 卸载指定卷 示例
let volumeId = ""; volumemanager.unmount(volumeId).then(function(flag){ // do something });
1
2
3
4
volumemanager.unmount
unmount(volumeId: string, callback:AsyncCallback<boolean>):void
异步卸载指定卷,以callback方式返回。
系统能力:SystemCapability.FileManagement.StorageService.Volume
参数
参数名 类型 必填 说明 volumeId string 是 卷id callback callback:AsyncCallback<boolean> 是 卸载指定卷之后的回调 示例
let volumeId = ""; volumemanager.unmount(volumeId, function(error, flag){ // do something });
1
2
3
4
Volume
系统能力:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.Volume。
属性
名称 | 类型 | 说明 |
---|---|---|
id | number | 卷id |
uuid | string | 卷uuid |
description | string | 卷相关描述 |
removable | boolean | 是否为可移动存储设备 |
state | int | 当前卷状态 |
path | string | 卷的挂载地址 |