/**下午4:47:54
 * @author zhangyh2
 * CleanCache.java
 * TODO
 */
package com.darly.dlclent.common;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.darly.dlclent.R;
import com.darly.dlclent.base.APPEnum;

/**
 * @author zhangyh2 CleanCache 下午4:47:54 TODO 清理文件缓存
 */
public class CleanCache {

	/**
	 * 
	 * 下午5:44:12
	 * 
	 * @author Zhangyuhui SetFragment.java TODO 清理缓存。
	 */
	public static void cleanCach() {
		// TODO Auto-generated method stub
		boolean isSuccess = false;
		List<File> files = new ArrayList<File>();
		files.add(new File(APPEnum.ROOT));
		files.add(new File(APPEnum.MAINRADIO));
		files.add(new File(APPEnum.IMAGE));
		files.add(new File(APPEnum.LOG));
		for (File file : files) {
			isSuccess = deleteDir(file);
		}
		if (isSuccess) {
			ToastApp.showToast(R.string.set_cache_succ);
		} else {
			ToastApp.showToast(R.string.set_cache_fail);
		}
	}

	/**
	 * @param dir
	 * @return 下午5:48:03
	 * @author Zhangyuhui SetFragment.java TODO 递归删除文件
	 */
	private static boolean deleteDir(File dir) {
		if (dir.isDirectory()) {
			String[] children = dir.list();
			
			// 递归删除目录中的子目录下
			for (int i = 0; i < children.length; i++) {
				boolean success = deleteDir(new File(dir, children[i]));
				if (!success) {
					return false;
				}
			}
		}
		dir.delete();
		// 目录此时为空，可以删除
		return true;
	}
}

@@ -1293,16 +1293,39 @@
 %09%09%7D%0A%09%09%7D%0A
+%09%09if (dir.isFile()) %7B%0A%09
 %09%09dir.de
@@ -1332,16 +1332,20 @@
 lete();%0A
+%09%09%7D%0A
 %09%09// %E7%9B%AE%E5%BD%95%E6%AD%A4

Clear the cache, delete files, do not use clean folders, so keep the folder