Android Directory Delete deleteDirectory(File dir)

Here you can find the source of deleteDirectory(File dir)

Description

delete Directory

License

Open Source License

Declaration

public static void deleteDirectory(File dir) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static void deleteDirectory(File dir) {
        if (!dir.exists())
            return;
        File[] subs = dir.listFiles();
        if (subs != null) {
            for (File f : dir.listFiles()) {
                if (f.isFile()) {
                    if (!f.delete()) {
                        throw new IllegalStateException(
                                "delete file failed: " + f);
                    }//w w w  .  ja v a2  s . c o  m
                } else {
                    deleteDirectory(f);
                }
            }
        }
        if (!dir.delete()) {
            throw new IllegalStateException("delete directory failed: "
                    + dir);
        }
    }
}

Related

  1. deleteContents(String directory)
  2. deleteDir(File pDirectory)
  3. deleteDir(String path)
  4. deleteDirectory(File dir)
  5. deleteDirectory(File directory)
  6. deleteDirectory(File directory)
  7. deleteDirectory(File path)
  8. deleteDirectory(File path)