开发者

How to get Storage size of the Application

开发者 https://www.devze.com 2023-02-09 04:41 出处:网络
How do I get the storage size of all installed applications, programmatically, which are also disp开发者_C百科layed over application\'s ApplicationInfo page?You could call

How do I get the storage size of all installed applications, programmatically, which are also disp开发者_C百科layed over application's ApplicationInfo page?


You could call

Process process = Runtime.getRuntime().exec(commandLine);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

with commandLine something like ls -l /data/app/*.apk or ls -l /data/app-private

and parse the resulting data to get the information you need.


There is no public API to get this information. But there is a workaround using reflection and IPackageStatsObserver. Here is a description of how to get code size. You can get cache size and data size in the same way.

0

精彩评论

暂无评论...
验证码 换一张
取 消