PHP教程

php直播源码,Android 获取空间大小

本文主要是介绍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 获取空间大小相关的代码, 更多内容欢迎关注之后的文章

这篇关于php直播源码,Android 获取空间大小的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!