Android PackageStats gives negative Values

just tried on API 23/24 and can just instance it.

these external* properties might refer to the SD card.

    PackageStats stats = new PackageStats(context.getPackageName());
    long codeSize  = stats.codeSize + stats.externalCodeSize;
    long dataSize  = stats.dataSize + stats.externalDataSize;
    long cacheSize = stats.cacheSize + stats.externalCacheSize;
    long appSize   = codeSize + dataSize + cacheSize;

Leave a Comment