Android Android loops video recording and detects memory card capacity
/** * Loop video when memory card capacity is less than 300M ", automatically delete the video list in the first 1 A file */ private void xunhuanluxiang() { if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { File path = Environment.getExternalStorageDirectory(); // achieve sdcard The file path StatFs statfs = new StatFs(path.getPath()); // To obtain block the SIZE long blocSize = statfs.getBlockSize(); // To obtain BLOCK The number of long totalBlocks = statfs.getBlockCount(); // F the use of Block The number of long availaBlock = statfs.getAvailableBlocks(); // Gets the current available memory capacity, unit: MB long sd = availaBlock * blocSize / 1024 / 1024; if (sd < 300) { String filepath = (Environment.getExternalStorageDirectory() .getAbsolutePath() + "/video/"); File file = new File(filepath); if (!file.exists()) { file.mkdirs(); } File[] files = file.listFiles(); if (files.length > 0) { String childFile[] = file.list(); String dele = (filepath + childFile[0]); File file2 = new File(dele); file2.delete(); } } } else if (Environment.getExternalStorageState().equals( Environment.MEDIA_REMOVED)) { Toast.makeText(this, " Please insert the memory card ", Toast.LENGTH_SHORT).show(); } }