未验证 提交 8fdfdf3d 编写于 作者: O openharmony_ci 提交者: Gitee

!1751 #I4TPCY已完成,请审核

Merge pull request !1751 from Annie_wang/PR1467
......@@ -19,7 +19,7 @@
- [Media](js-apis-media.md)
- Security
- [User Authentication](js-apis-useriam-userauth.md)
- [Access Control](js-apis-abilityAccessCtrl.md)
- [Access Control](js-apis-abilityAccessCtrl.md)
- Data Management
- [File Management](js-apis-fileio.md)
- [Lightweight Storage](js-apis-data-storage.md)
......@@ -27,8 +27,16 @@
- [Relational Database](js-apis-data-rdb.md)
- [Result Set](js-apis-data-resultset.md)
- [DataAbilityPredicates](js-apis-data-ability.md)
- File Management
- [File Management](js-apis-fileio.md)
- [Statfs](js-apis-statfs.md)
- [Environment](js-apis-environment.md)
- [Public File Access and Management](js-apis-filemanager.md)
- [App Storage Statistics](js-apis-storage-statistics.md)
- [Volume Management](js-apis-volumemanager.md)
- Account Management
- [Distributed Account Management](js-apis-distributed-account.md)
- [App Account Management](js-apis-appAccount.md)
- Telephony Service
- [Call](js-apis-call.md)
- [SMS](js-apis-sms.md)
......@@ -38,7 +46,7 @@
- [WLAN](js-apis-wifi.md)
- Device Management
- [Sensors](js-apis-sensor.md)
- [Vibration](js-apis-vibrator.md)
- [Vibrator](js-apis-vibrator.md)
- [Brightness](js-apis-brightness.md)
- [Battery Info](js-apis-battery-info.md)
- [Power Management](js-apis-power.md)
......
# App Storage Statistics
> ![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.
## Modules to Import
```js
import storagestatistics from "@ohos.storagestatistics";
```
## System Capabilities
SystemCapability.FileManagement.StorageService.SpatialStatistics
## storagestatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string): Promise<number>
Asynchronously obtains the total space of the specified volume. This method uses a promise to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes| Universally unique identifier (UUID) of the volume.|
- Return value
| Type| Description|
| --------------------- | ---------------- |
| Promise<number> | Promise used to return the total space of the volume.|
- Example
```js
let uuid = "";
storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){
console.info("getTotalSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getTotalSizeOfVolume failed with error:"+ err);
});
```
## storagestatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
Asynchronously obtains the total space of the specified volume. This method uses a callback to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes| UUID of the volume.|
| callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the total space of the volume.|
- Example
```js
let uuid = "";
storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){
// Do something
});
```
## storagestatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string): Promise<number>
Asynchronously obtains the available space of the specified volume. This method uses a promise to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes| UUID of the volume.|
- Return value
| Type| Description|
| --------------------- | ------------------ |
| Promise<number> | Promise used to return the available space of the volume.|
- Example
```js
let uuid = "";
storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){
console.info("getFreeSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getFreeSizeOfVolume failed with error:"+ err);
});
```
## storagestatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | Yes| UUID of the volume.|
| callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the available space of the volume.|
- Example
```js
let uuid = "";
storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){
// Do something
});
```
## storagestatistics.getBundleStats
getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats>
Asynchronously obtains the bundle status on the specified volume. This method uses a promise to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ----------- | ------ | ---- | -------- |
| volumeUuid | string | Yes| UUID of the volume.|
| packageName | string | Yes| Bundle name of the app.|
- Return value
| Type| Description|
| ------------------------------------------ | -------------------------- |
| Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.|
- Example
```js
let uuid = "";
let packageName = "";
storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
}).catch(function(err){
console.info("getBundleStats failed with error:"+ err);
});
```
## storagestatistics.getBundleStats
getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void
Asynchronously obtains the bundle status on the specified volume. This method uses a callback to return the result.
- Parameters
| Name| Type| Mandatory| Description|
| ---------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| volumeUuid | string | Yes| UUID of the volume.|
| callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes| Callback invoked to return the bundle status on the volume.|
- Example
```js
let uuid = "";
let packageName = "";
storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){
// Do something
});
```
## BundleStats
### Attributes
| Name| Type| Description|
| --------- | ------ | -------------- |
| appSize | number | Size of the app.|
| cacheSize | number | Size of the cached data.|
| dataSize | number | Total data size of the app.|
# Volume 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.
## Modules to Import
```js
import volumemanager from "@ohos.volumemanager";
```
## System Capabilities
SystemCapability.FileManagement.StorageService.Volume
## volumemanager.getAllVolumes
getAllVolumes(): Promise<Volume[]>
Asynchronously obtains information about all available volumes. This method uses a promise to return the result.
- 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<Volume[]>):void
Asynchronously obtains information about all available volumes. This method uses a callback to return the result.
- 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.
- 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 mounts a volume. This method uses a callback to return the result.
- 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.
- 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.
- 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
### Attributes
| Name| Type| Description|
| ----------- | ------- | -------------------- |
| id | number | Volume ID.|
| uuid | string | Universally unique identifier (UUID) of the volume.|
| description | string | Description of the volume.|
| removeAble | boolean | Whether the volume is a removable storage device.|
| state | int | Current volume status.|
| path | string | Mount address of the volume.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册