Looping video, it sounds is not very tall, in fact, the principle is to detect memory card capacity, less than a certain value automatically delete the specified folder, this monitoring or car recorder will be useful.
/** * Loop recording, when the memory card capacity is less than 300M, automatically delete the first file inside the video list */private void xunhuanluxiang () {if (Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {file path = environment.getexternalstoragedirectory ();// get sdcard file path statfs statfs = new StatFs (Path.getpath ());// get Block's sizelong blocsize = statfs.getblocksize ();// Gets the number of blocks Long totalblocks = statfs.getblockcount ();// used by the block Long availablock = statfs.getavailableblocks ();// Gets the current available memory capacity, in units: mblong 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 memory card", toast.length_short). Show ();}}
Android cycle recording, detect memory card capacity, less than a certain value automatically delete the specified folder