Android cycle recording, detect memory card capacity, less than a certain value automatically delete the specified folder

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.