// 存储空间总共的大小
public static String getRomTotalSpace(Context context) {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return Formatter.formatFileSize(context, blockSize * totalBlocks);
}
//可用存储空间
public static String getRomAvailableSpace(Context context) {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return Formatter.formatFileSize(context, availableBlocks * blockSize);
}
获取手机存储空间大小
最新推荐文章于 2021-05-26 02:17:31 发布