//加上创建的名字 File file = new File(sdCard,"xxhuang.text"); FileOutputStream fos = new FileOutputStream(file);
获得sd卡状态(手机是否有sd卡):
1
Environment.getExternalStorageState();
获得手机内存/sd卡内存状态:
1
Environment.getExternalStorageState()
获得手机内存/sd卡总空间和可用空间:
1 2 3 4 5 6 7 8
//获得磁盘状态对象 ,并传入路径 StatFs statFs = new StatFs(path.getPath()); long blookSize = statFs.getBlockSizeLong(); //获得单个磁盘扇区大小 long blockCount = statFs.getBlockCountLong();//获得扇区总数 long availableBlock = statFs.getAvailableBlocksLong();//获得可用扇区数量