php直播源码,Android 获取空间大小
作者:互联网
php直播源码,Android 获取空间大小相关的代码
public static void readSDCard() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs statFs = new StatFs(sdcardDir.getPath());
long blockSize = statFs.getBlockSize();
long blockCount = statFs.getBlockCount();
long availCount = statFs.getAvailableBlocks();
Log.d("gggg", "block大小:" + blockSize + ",block数目:" + blockCount + ",总大小:" + blockSize * blockCount / 1024 + "KB");
Log.d("gggg", "可用的block数目::" + availCount + ",剩余空间:" + availCount * blockSize / 1024 + "KB");
}
}
/**
* 获取总空间大小
*
* @return 单位KB
*/
public static long totalSize() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs statFs = new StatFs(sdcardDir.getPath());
long blockSize = statFs.getBlockSize();
long blockCount = statFs.getBlockCount();
return blockSize * blockCount / 1024;
}
return 0;
}
/**
* 剩余空间大小
*
* @return 单位KB
*/
public static long availSize() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs statFs = new StatFs(sdcardDir.getPath());
long blockSize = statFs.getBlockSize();
long availCount = statFs.getAvailableBlocks();
return availCount * blockSize / 1024;
}
return 0;
}
以上就是php直播源码,Android 获取空间大小相关的代码, 更多内容欢迎关注之后的文章
标签:sdcardDir,statFs,long,Environment,state,源码,blockSize,Android,php 来源: https://blog.csdn.net/yb1314111/article/details/116492277