본문 바로가기
프로그래밍/Android

Android File folder delete

by CaffeLatte 2014. 11. 23.

/**

   * 폴더 삭제

   * @param path

   * @return

   */

  public static int deleteDir(String path) {

    File file = new File(path);

    if (file.exists()) {

      File[] childFileList = file.listFiles();

      for (File childFile : childFileList) {

        if (childFile.isDirectory()) {

          deleteDir(childFile.getAbsolutePath());

        } else {

          childFile.delete();

        }

      }

      file.delete();

      return 1;

    } else {

      return 0;

    }

  }

댓글