How to get Storage size of the Application
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.
精彩评论