Android Directory Delete deleteDir(File pDirectory)

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

Description

delete Dir

License

Apache License

Parameter

Parameter Description
pDirectory a parameter

Declaration

public static void deleteDir(File pDirectory) 

Method Source Code

//package com.java2s;
/**//from  www  . j  a va 2s  .  c o  m
 Copyright 2014 Jens Glufke

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 * -----------------------------------------------------------------------<br>
 * 
 * class that can be used to operations on files like copy, deleteDir etc 
 */

import java.io.File;

public class Main {
    /**
     * 
     * @param pDirectory
     */
    public static void deleteDir(File pDirectory) {
        if (pDirectory.exists()) {
            if (pDirectory.isDirectory()) {
                for (File lFile : pDirectory.listFiles()) {
                    if (!lFile.equals(pDirectory.getParentFile())) {
                        deleteDir(lFile);
                    }
                }
            }
            pDirectory.delete();
        }
    }
}

Related

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