Android安卓中循环录像并检测内存卡容量
作者:junjie 时间:2021-06-21 13:12:55
/**
* 循环录像,当内存卡容量少于300M时,自动删除视频列表里面的第一个文件
*/
private void xunhuanluxiang() {
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {
File path = Environment.getExternalStorageDirectory();
// 取得sdcard文件路径
StatFs statfs = new StatFs(path.getPath());
// 获取block的SIZE
long blocSize = statfs.getBlockSize();
// 获取BLOCK数量
long totalBlocks = statfs.getBlockCount();
// 己使用的Block的数量
long availaBlock = statfs.getAvailableBlocks();
// 获取当前可用内存容量,单位: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, "请插入内存卡", Toast.LENGTH_SHORT).show();
}
}
标签:Android,安卓,循环录像,检测,内存卡,容量
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
JAVA JNI函数的注册过程详细介绍
2023-02-07 18:41:17
flutter实现扫码枪获取数据源禁止系统键盘弹窗示例详解
2023-07-23 01:52:41
![](https://img.aspxhome.com/file/2023/0/96760_0s.webp)
java compare compareTo方法区别详解
2022-06-26 08:13:55
Java微信支付-微信红包
2023-11-01 01:07:05
![](https://img.aspxhome.com/file/2023/6/66166_0s.png)
springboot中使用Feign整合nacos,gateway进行微服务之间的调用方法
2021-07-12 07:00:28
![](https://img.aspxhome.com/file/2023/4/69304_0s.png)
Java实现有限状态机的推荐方案分享
2022-01-07 15:54:27
![](https://img.aspxhome.com/file/2023/9/77989_0s.png)
一篇文章带你搞定JAVA反射
2023-09-18 02:27:51
![](https://img.aspxhome.com/file/2023/3/78023_0s.png)
详解MyBatis的Dao层实现和配置文件深入
2022-07-26 02:29:17
![](https://img.aspxhome.com/file/2023/6/61246_0s.jpg)
C# memcached缓存使用实例代码
2022-01-15 02:17:11
Mybatis-Plus 条件构造器 QueryWrapper 的基本用法
2022-07-07 13:28:18
![](https://img.aspxhome.com/file/2023/0/92560_0s.png)
Java swing 图像处理多种效果实现教程
2022-08-16 20:15:08
![](https://img.aspxhome.com/file/2023/0/77960_0s.jpg)
Java读取本地json文件及相应处理方法
2023-10-16 16:37:34
集合嵌套之ArrayList嵌套ArrayList实例
2021-06-23 07:32:25
SpringBoot和Vue.js实现的前后端分离的用户权限管理系统
2023-09-03 14:37:33
JAVA的Random类的用法详解
2022-07-22 00:05:58
win7中C#的winForm编程使用savefiledialog不能弹出保存窗体的解决方法
2022-09-18 07:27:57
Java基础:流Stream详解
2023-11-29 06:11:14
![](https://img.aspxhome.com/file/2023/6/60086_0s.jpg)
C#使用GET、POST请求获取结果
2023-04-20 13:35:43
IDEA中的maven没有dependencies解决方案
2021-08-01 11:58:50
![](https://img.aspxhome.com/file/2023/1/66641_0s.png)
SSH框架网上商城项目第1战之整合Struts2、Hibernate4.3和Spring4.2
2023-04-19 15:01:55
![](https://img.aspxhome.com/file/2023/6/68736_0s.png)