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 */



你可能感兴趣的:(android)