提交 817477ce 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 1e34c998
# App Storage Statistics # App Storage Statistics
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> >
> - 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 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.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable. > - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
Obtains storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
## Modules to Import ## Modules to Import
...@@ -15,10 +17,14 @@ import storagestatistics from "@ohos.storageStatistics"; ...@@ -15,10 +17,14 @@ import storagestatistics from "@ohos.storageStatistics";
getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt; getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the total space of the specified volume. This API uses a promise to return the result. Asynchronously obtains the total size of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -29,7 +35,7 @@ Asynchronously obtains the total space of the specified volume. This API uses a ...@@ -29,7 +35,7 @@ Asynchronously obtains the total space of the specified volume. This API uses a
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total space of the volume.| | Promise&lt;number&gt; | Promise used to return the total size of the volume.|
- Example - Example
...@@ -46,16 +52,20 @@ Asynchronously obtains the total space of the specified volume. This API uses a ...@@ -46,16 +52,20 @@ Asynchronously obtains the total space of the specified volume. This API uses a
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
Asynchronously obtains the total space of the specified volume. This API uses a callback to return the result. Asynchronously obtains the total size of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the volume.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
- Example - Example
...@@ -75,8 +85,12 @@ getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt; ...@@ -75,8 +85,12 @@ getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result. Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -107,8 +121,12 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):vo ...@@ -107,8 +121,12 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):vo
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result. Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -130,21 +148,25 @@ Asynchronously obtains the available space of the specified volume. This API use ...@@ -130,21 +148,25 @@ Asynchronously obtains the available space of the specified volume. This API use
getBundleStats(packageName: string): Promise&lt;BundleStats&gt; getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
Asynchronously obtains app information. This API uses a promise to return the result. Asynchronously obtains space information of an application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- | | ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the app.| | packageName | string | Yes | Bundle name of the application.|
- Return value - Return value
| Type | Description | | Type | Description |
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the app information.| | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
- Example - Example
...@@ -161,16 +183,20 @@ Asynchronously obtains app information. This API uses a promise to return the re ...@@ -161,16 +183,20 @@ Asynchronously obtains app information. This API uses a promise to return the re
getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains app information. This API uses a callback to return the result. Asynchronously obtains space information of an application. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters - Parameters
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the app.| | packageName | string | Yes | Bundle name of the application.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the app information.| | callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.|
- Example - Example
...@@ -182,14 +208,310 @@ Asynchronously obtains app information. This API uses a callback to return the r ...@@ -182,14 +208,310 @@ Asynchronously obtains app information. This API uses a callback to return the r
}); });
``` ```
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise<BundleStats>
Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Return value
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
- Example
```js
let bundleStats = await storageStatistics.getCurrentBundleStats();
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
```
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void
Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. |
- Example
```js
storagestatistics.getCurrentBundleStats(function(error, bundleStats){
// Do something.
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
});
```
## BundleStats<sup>9+</sup> ## BundleStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
### Attributes - Attributes
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize | number | Size of the application. |
| cacheSize | number | Cache size of the application. |
| dataSize | number | Total data size of the application.|
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise<number>
Obtains the total space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
- Example
```js
let number = await storageStatistics.getTotalSize();
console.info("getTotalSize successfully:"+ JSON.stringify(number));
```
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback<number>): void
Obtains the total space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
- Example
```js
storagestatistics.getTotalSize(function(error, number){
// Do something.
console.info("getTotalSize successfully:"+ JSON.stringify(number));
});
```
## storagestatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise<number>
Obtains the available space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
- Example
```js
let number = await storageStatistics.getFreeSize();
console.info("getFreeSize successfully:"+ JSON.stringify(number));
```
## storagestatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback<number>): void
Obtains the available space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
- Example
```js
storagestatistics.getFreeSize(function(error, number){
// Do something.
console.info("getFreeSize successfully:"+ JSON.stringify(number));
});
```
## storagestatistics.getSystemSize<sup>9+</sup>
getSystemSize(): Promise&lt;number&gt;
Asynchronously obtains the system space. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system space obtained.|
- Example
```js
storagestatistics.getSystemSize().then(function(number){
console.info("getSystemSize successfully:"+ number);
}).catch(function(err){
console.info("getSystemSize failed with error:"+ err);
});
```
## storagestatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback:AsyncCallback&lt;number&gt;):void
Asynchronously obtains the system space. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
- Example
```js
storagestatistics.getSystemSize(function(error, number){
// Do something.
console.info("getSystemSize successfully:"+ number);
});
```
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string): Promise&lt;StorageStats&gt;
Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| userId | string | No | User ID.<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
- Return value
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.|
- Example
```js
let userId = "";
storagestatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){
console.info("getUserStorageStats failed with error:"+ err);
});
```
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string, callback:AsyncCallback&lt;StorageStats&gt;):void
Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | string | No | User ID.<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes | Callback invoked to return the information obtained.|
- Example
```js
storagestatistics.getUserStorageStats(userId, function(error, StorageStats){
// Do something.
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
});
```
## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Attributes
| Name | Type | Description | | Name | Type | Description |
| --------- | ------ | -------------- | | --------- | ------ | -------------- |
| appSize<sup>9+</sup> | number | Size of the app. | | total | number | Total space of the built-in memory card. |
| cacheSize<sup>9+</sup> | number | Cache size of the app. | | audio | number | Space occupied by audio data. |
| dataSize<sup>9+</sup> | number | Total data size of the app.| | video | number | Space occupied by video data.|
| image | number | Space occupied by image data. |
| file | number | Space occupied by files. |
| app | number | Space occupied by application data.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册