Recording videos in Android and detecting memory card capacity
Updated: June 9, 2015 10:21:08 Submission: junjie
This article mainly introduces the cyclic recording of Android and the detection of memory card capacity. When the memory card space is full, this article also automatically deletes the first file in the video list. Friends who need it can refer to it.
/** * Record the video loop. When the memory card capacity is less than 300M, the first file in the video list will be automatically deleted. */ private void xunhuanluxiang() { if (().equals( Environment.MEDIA_MOUNTED)) { File path = (); // Get the sdcard file path StatFs statfs = new StatFs(()); // Get the SIZE of the block long blocSize = (); // Get the number of BLOCKs long totalBlocks = (); // The number of blocks used long availaBlock = (); // Get the current available memory capacity, unit: MB long sd = availaBlock * blocSize / 1024 / 1024; if (sd < 300) { String filepath = (() .getAbsolutePath() + "/video/"); File file = new File(filepath); if (!()) { (); } File[] files = (); if ( > 0) { String childFile[] = (); String dele = (filepath + childFile[0]); File file2 = new File(dele); (); } } } else if (().equals( Environment.MEDIA_REMOVED)) { (this, "Please insert the memory card", Toast.LENGTH_SHORT).show(); } }
Related Articles
Android development performance optimization summary
This article mainly introduces relevant information about the summary of Android development performance optimization. It is very good and has reference value. Friends who need it can refer to it.2016-09-09Detailed explanation of the use of WebView and back key processing in Android
Since the blogger started writing Android, he has been suffering from the destruction of WebView. Fortunately, a lot of great masters on the Internet have given them the pitfalls they encountered on their growth path and some solutions. This article mainly introduces relevant information about the use of WebView and back key processing in Android. Friends who need it can refer to it.2024-04-04Use of Android Spinner drop-down menu
The drop-down menu in Android, such as <select> in html, is the key to calling the setDropDownViewResource method to define the appearance of the drop-down menu in XML.2013-04-04Android touch event listening (Activity layer, ViewGroup layer, View layer) detailed introduction
This article mainly introduces the relevant information introduced in detail by Android touch event monitoring (Activity layer, ViewGroup layer, View layer). Friends who need it can refer to it.2016-12-12Detailed explanation of Android WindowManger hierarchy analysis
This article mainly introduces the detailed explanation of the hierarchical analysis of Android WindowManger. This article explains the understanding and use of this technology through brief cases. The following is the detailed content. Friends who need it can refer to it.2021-09-09Detailed explanation of the method of obtaining the sliding distance of RecyclerView on Android
RecyclerView is a more powerful control for Android. It not only achieves the same effect as ListView, but also optimizes various shortcomings in ListView. It can realize vertical scrolling of data or horizontal scrolling (ListView cannot perform horizontal scrolling). Next, explain the usage of RecyclerView2023-01-01Android programming method to load and wait for ProgressDialog
This article mainly introduces the method of loading and waiting ProgressDialog in Android. The example analyzes the specific usage method of loading the waiting class ProgressDialog in Android. Friends who need it can refer to it2015-12-12Methods for implementing HashMap sorting in Android
This article mainly introduces the method of implementing HashMap sorting in Android. It is a very classic sorting algorithm. Friends who need it can refer to it.2014-08-08RecyclerView implements insertion and deletion
This article mainly introduces the implementation of RecyclerView insertion and deletion in detail, which has certain reference value. Interested friends can refer to it.2018-08-08How to make Android floating background effect
This article mainly introduces the production code of Android floating background effect in detail, which has certain reference value. Interested friends can refer to it.2017-02-02