• Home
Name Date Size #Lines LOC

..--

AppScope/06-May-2025-3633

entry/06-May-2025-2,1791,975

hvigor/06-May-2025-2322

screenshots/device/06-May-2025-

.gitignoreD06-May-202556 55

README.mdD06-May-20253 KiB4523

README_zh.mdD06-May-20255.2 KiB8862

build-profile.json5D06-May-20251.1 KiB4342

hvigorfile.jsD06-May-2025168 21

hvigorwD06-May-20252.1 KiB6428

hvigorw.batD06-May-20252 KiB7356

oh-package.json5D06-May-2025819 2725

ohosTest.mdD06-May-2025628 108

README.md

1# Storage Space Statistics
2
3### Introduction
4
5This sample presents how to view the storage space usage, space of all installed applications, and available volumes of a device by using the application bundle management, application space statistics, and volume management modules.
6
7This sample uses the [<**DataPanel** component>](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-datapanel.md) to display the space information about different applications; uses [**Bundle**](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-ability-kit/js-apis-Bundle.md) to obtain the application name and bundle information; uses [**App Space Statistics**](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-storage-statistics.md) to obtain the storage space usage of the device; use [**Volume Management**](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-core-file-kit/js-apis-file-volumemanager-sys.md) to obtain information about available volumes of the device.
8Instructions:
9
101. The main page displays the detailed information about the storage space usage of the current device.
11
122. Tap **Application** to view the space of all installed applications.
13
143. Tap **View Available Volumes** to view information about all available volumes of the device.
15
16
17
18### Display Effect
19
20![](./screenshots/device/main_page_en.png)
21![](./screenshots/device/application_page_en.png)
22![](./screenshots/device/volume_page_en.png)
23
24### Required Permissions
25
26- Permission to obtain storage space information and available volumes: [ohos.permission.STORAGE_MANAGER](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/AccessToken/permissions-for-system-apps.md)
27
28- Permission to obtain information about installed applications: [ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/AccessToken/permissions-for-enterprise-apps.md)
29
30### Dependency
31
32N/A
33
34### Constraints
35
361. This sample can only be run on standard-system devices that use the Rockchip RK3568 development board.
37
382. This sample is based on the stage model, which is supported from API version 10 (API Version 10 Release).
39
403. DevEco Studio (4.0 Release) must be used.
41
424. This sample uses the **@ohos.bundle.innerBundleManager**, **@ohos.volumeManager**, and **@ohos.storageStatistics** system APIs. To use the full SDK, obtain it from a mirror site and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](https://gitee.com/openharmony/docs/blob/master/en/application-dev/faqs/full-sdk-switch-guide.md/).
43
445. This example uses the **system_core** permissions (see [App Permission List](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/AccessToken/permissions-for-system-apps.md)). You need to [configure a high-level permission signature](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/hapsigntool-overview.md/).
45

README_zh.md

1# 存储空间统计(仅对系统应用开放)
2
3### 介绍
4
5本示例通过应用程序包管理、应用空间统计与卷管理模块,实现了查看当前设备存储空间信息、所有安装的应用的存储信息、所有可用卷的存储信息的功能。
6
7### 效果预览
8
9| 存储空间统计                          | 应用存储信息                                            | 可用卷信息                    |
10|---------------------------------|---------------------------------------------------|--------------------------|
11| ![](./screenshots/device/main_page_zh.png) | ![](./screenshots/device/application_page_zh.png) | ![](./screenshots/device/volume_page_zh.png) |
12
13使用说明:
14
151. 主页面会展示当前设备存储使用的详细信息。
16
172. 点击“应用”,可以查看当前安装的所有应用的存储使用情况。
18
193. 当有可用的卷时,点击“查看可用卷信息”查看当前设备所有的可用卷的存储使用情况。
20
21### 工程目录
22```
23entry/src/main/ets/
24|---Application
25|   |---MyAbilityStage.ts
26|---common
27|   |---ParseData.ets                         // 数据
28|   |---QueryStorageData.ets                  // 空间
29|   |---QueryVolumeData.ets                   // 可用卷
30|   |---TitleBar.ets                          // 标题
31|---MainAbility
32|   |---MainAbility.ts
33|---model
34|   |---AppData.ets                           // 应用数据
35|   |---StorageData.ets                       // 存储空间
36|   |---VolumeData.ets                        // 可用卷使用
37|---pages
38|   |---AppInfo.ets                           // 应用详情
39|   |---MainPage.ets                          // 主页
40|   |---StorageList.ets                       // 空间列表
41|   |---VolumeList.ets                        // 可用卷列表
42|---utils
43|   |---CheckEmptyUtils.ets                   // 判空方法
44|   |---Logger.ts                             // 日志工具
45|   |---StorageConst.ets
46```
47### 具体实现
48
49* 本示例使用DataPanel组件展示不同种类的应用存储信息,通过 Bundle模块来获取不同应用的包名与应用名等信息,使用应用空间统计来查询当前设备的存储使用情况,使用卷管理来查询可用卷存储使用情况。
50* 源码链接:[QueryStorageData.ets](entry/src/main/ets/common/QueryStorageData.ets),[QueryVolumeData.ets](entry/src/main/ets/common/QueryVolumeData.ets)
51* 接口参考:[DataPanel组件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-datapanel.md),[@ohos.bundle.bundleManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-bundleManager-sys.md),[@ohos.file.storageStatistics](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-storage-statistics-sys.md),[@ohos.file.volumeManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-volumemanager-sys.md)
52
53### 相关权限
54
551. 允许获取存储信息与可用卷信息:[ohos.permission.STORAGE_MANAGER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstorage_manager)
56
572. 允许获取已安装应用的信息:[ohos.permission.GET_BUNDLE_INFO_PRIVILEGED](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_bundle_info_privileged)
58
593. 允许应用读取已安装应用列表:[ohos.permission.GET_INSTALLED_BUNDLE_LIST](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionget_installed_bundle_list)
60
61### 依赖
62
63不涉及。
64
65### 约束与限制
66
671. 本示例仅支持标准系统上运行,支持设备:RK3568。
68
692. 本示例为Stage模型,已适配API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)。
70
713. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
72
734. 本示例需要使用@ohos.bundle.innerBundleManager,@ohos.volumeManager,@ohos.storageStatistics系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEcoStudio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)74
755. 本示例使用了system_core级别的权限(相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))76
77### 下载
78
79如需单独下载本工程,执行如下命令:
80```
81git init
82git config core.sparsecheckout true
83echo code/SystemFeature/DEviceManagement/StorageStatistic/ > .git/info/sparse-checkout
84git remote add origin https://gitee.com/openharmony/applications_app_samples.git
85git pull origin master
86
87```
88