赞
踩
- public void deleteFile(File file) {
- if (file.exists()) {
- if (file.isFile()) {
- file.setExecutable(true, false);
- file.setReadable(true, false);
- file.setWritable(true, false);
- file.delete();
- } else if (file.isDirectory()) {
- File files[] = file.listFiles();
- for (int i = 0; i < files.length; i++) {
- this.deleteFile(files[i]);
- }
- }
- file.setExecutable(true, false);
- file.setReadable(true, false);
- file.setWritable(true, false);
- file.delete();
- Toast.makeText(MainActivity.this, "文件已删除", Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(MainActivity.this, "文件不存在", Toast.LENGTH_LONG).show();
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。