android 获取存储空间大小

# 获取 External Storage 上的存储空间/可用存储空间大小

StatFs state = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
long blockSize = state.getBlockSize();
long blockCount = state.getBlockCount();
long availableCount = state.getAvailableBlocks();
long totalSpace = blockCount * blockSize / 1024; /* 存储空间大小 in KB */
long freeSpace = availableCount * blockSize / 1024; /* 可用的存储空间大小 in KB */



转载于:https://www.cnblogs.com/tracydj/archive/2011/12/12/2284972.html

你可能感兴趣的:(android 获取存储空间大小)