android手机内部存储空间和外部存储空间获取代码
2010-08-21 03:22:00 来源:WEB开发网核心提示:return totalBlocks * blockSize;} else {return ERROR;}}static public String formatSize(long size) {String suffix = null;if (size >= 1024) {suffix = "KiB&
return totalBlocks * blockSize;
} else {
return ERROR;
}
}
static public String formatSize(long size) {
String suffix = null;
if (size >= 1024) {
suffix = "KiB";
size /= 1024;
if (size >= 1024) {
suffix = "MiB";
size /= 1024;
}
}
StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
int commaOffset = resultBuffer.length() - 3;
while (commaOffset > 0) {
resultBuffer.insert(commaOffset, ',');
commaOffset -= 3;
}
if (suffix != null)
resultBuffer.append(suffix);
return resultBuffer.toString();
}
}
更多精彩
赞助商链接