I need to display the size of every application installed in my phone! How can I achieve this? I tried this:
PackageStats ps = new PackageStats(packageInfo.packageName);
int size = ps.codeSize;
I am getting a 0 value every time. Please help me
I need to display the size of every application installed in my phone! How can I achieve this? I tried this:
PackageStats ps = new PackageStats(packageInfo.packageName);
int size = ps.codeSize;
I am getting a 0 value every time. Please help me
From Getting installed app size
Unfortunately there is currently no official way to do that. However, you can call the PackageManager's hidden getPackageSize method if you import the PackageStats and IPackageStatsObserver AIDLs into our project and generate the stubs. You can then use reflection to invoke getPackageSize:
PackageManager pm = getPackageManager(); Method getPackageSizeInfo = pm.getClass().getMethod( "getPackageSizeInfo", String.class, IPackageStatsObserver.class); getPackageSizeInfo.invoke(pm, "com.android.mms", new IPackageStatsObserver.Stub() { @Override public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException { Log.i(TAG, "codeSize: " + pStats.codeSize); } });
That's obviously a big hack and should not be used for public applications.
Android Package Size Using AIDL with Eclipse and ADT APK Piracy: Using private code & resources in Android
You would then need to iterate through each application and put the package name within the invoke(...) method.