Android Folder Recursive Delete deleteFileAndFolder(File fileOrFolder)

Here you can find the source of deleteFileAndFolder(File fileOrFolder)

Description

delete File And Folder

Declaration

private static void deleteFileAndFolder(File fileOrFolder) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {
    private static void deleteFileAndFolder(File fileOrFolder) {
        if (fileOrFolder == null || !fileOrFolder.exists()) {
            return;
        }/* w  w w . j  a  va2s.  com*/
        if (fileOrFolder.isDirectory()) {
            File[] children = fileOrFolder.listFiles();
            if (children != null) {
                for (File childFile : children) {
                    deleteFileAndFolder(childFile);
                }
            }
        } else {
            fileOrFolder.delete();
        }
    }
}

Related

  1. rmr(File path)