Android File Delete deleteDir(File dir)

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

Description

delete Dir

Declaration

public static void deleteDir(File dir) throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.IOException;

public class Main {

    public static void deleteDir(File dir) throws IOException {
        if (dir.isFile())
            throw new IOException(
                    "IOException -> BadInputException: not a directory.");
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                if (file.isFile()) {
                    file.delete();//www.  j a v a 2s. co m
                } else {
                    deleteDir(file);
                }
            }
        }// if 
        dir.delete();
    }
}

Related

  1. delete(File toDelete)
  2. deleteAll(File file)
  3. deleteAndRename(File toDelete, File toRename)
  4. deleteApkInSystem(String fileName, int type)
  5. deleteDatabaseFile(int type, Context context)
  6. deleteDir(File dir)
  7. deleteDir(File spec)
  8. deleteDirContent(File d)
  9. deleteFile(File f)