linhaiczy 最近的时间轴更新
linhaiczy

linhaiczy

V2EX 第 597903 号会员,加入于 2022-10-18 21:45:32 +08:00
linhaiczy 最近回复了
2022-12-10 13:35:35 +08:00
回复了 linhaiczy 创建的主题 Android 安卓不同文件类型占用空间统计如何实现
ong totalBytes = storageStatsManager.getTotalBytes(uuid);
long freeBytes = storageStatsManager.getFreeBytes(uuid);
StorageStats storageStats = storageStatsManager.queryStatsForUser(uuid, user);
long appBytes = storageStats.getAppBytes();
long dataBytes = storageStats.getDataBytes();
ExternalStorageStats externalStorageStats = storageStatsManager.queryExternalStatsForUser(uuid,user);
long totalExternalUsedBytes = externalStorageStats.getTotalBytes();
long imageBytes = externalStorageStats.getImageBytes();
long audioBytes = externalStorageStats.getAudioBytes();
long videoBytes = externalStorageStats.getVideoBytes();

long appsSize = Utils.sub(Utils.add(appBytes, dataBytes).longValue(), totalExternalUsedBytes).longValue();
long otherSize = Utils.sub(totalExternalUsedBytes, imageBytes, audioBytes, videoBytes).longValue();
long dataSize = Utils.add(appBytes, dataBytes, freeBytes).longValue();
long system = Utils.sub(totalBytes, dataSize).longValue();
其中 appsSize 是计算的所有应用大小

目前是这么获取的,但总感觉有点问题
在用 adb 内存填充后,生成的文件会被统计到 storageStats.getDataBytes()中
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5198 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 09:28 · PVG 17:28 · LAX 02:28 · JFK 05:28
Developed with CodeLauncher
♥ Do have faith in what you're doing.