示例#1
0
 /**
  * 删除所有缓存文件.
  *
  * @return true, if successful
  */
 public static boolean clearDownloadFile() {
   try {
     File fileDirectory = new File(downloadRootDir);
     deleteFile(fileDirectory);
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
示例#2
0
  /**
   * 删除文件.
   *
   * @return true, if successful
   */
  public static boolean deleteFile(File file) {

    try {
      if (!isCanUseSD()) {
        return false;
      }
      if (file == null) {
        return true;
      }
      if (file.isDirectory()) {
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
          deleteFile(files[i]);
        }
      } else {
        file.delete();
      }

    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }