android获取设备空闲空间

        File path = Environment.getExternalStorageDirectory();
        StatFs stat = new StatFs(path.getPath());
        String totalStr = Formatter.formatFileSize(this, stat.getFreeBytes());
        String availStr = Formatter.formatFileSize(this, stat.getAvailableBytes());
        "设备空闲空间:"+totalStr+";可用空间:"+availStr;

你可能感兴趣的:(android)