其他分享
首页 > 其他分享> > android 获取存储空间大小

android 获取存储空间大小

作者:互联网

原文链接:http://www.cnblogs.com/tracydj/archive/2011/12/12/2284972.html

# 获取 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

标签:www,12,blockSize,long,获取,state,android,存储空间
来源: https://blog.csdn.net/weixin_30906671/article/details/97825524