I am trying to calculate apk file size of the installed applications. Here is the code
public class PackageTabActivity extends ListActivity{
private static f
Here is a hack from Joseph that worked for me. His original post can be found here
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);
}
});
ApplicationInfo tmpInfo = context.getPackageManager().getApplicationInfo(packageName,-1);
long size = new File(tmpInfo.sourceDir).length();