清理目录下的文件
private void maybeClear(final String excluded) {
File callDir = new File(mContext.getCacheDir(), "call_rec");
if (!callDir.exists()) {
return;
}
final File[] files = callDir.listFiles();
if (files == null || files.length <= 20) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
int count = 0;
for (File file : files) {
if (file.getAbsoluteFile().equals(excluded)) {
continue;
}
if (file.delete()) {
count++;
}
}
android.util.Log.d("CallRecorder", "Clear file " + count);
}
}).start();
}
Environment.getExternalStorageDirectory().getAbsolutePath()
posted on 2019-04-03 20:45 zhang11111wei 阅读(97) 评论(0) 编辑 收藏 举报