Android Directory Delete deleteDirectory(File path)

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

Description

delete Directory

License

Apache License

Declaration

public static boolean deleteDirectory(File path) 

Method Source Code

//package com.java2s;
/*//from   w  w w .j  a  va  2s  . co  m
 * Copyright 2012 the original author or authors.
 *
 * 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.
 *
 * Revision History
 * Author           Date                Description
 * ---------------  ----------------    ------------
 * Hyo-jeong Lee    2012. 8. 22.        First Draft.
 */

import java.io.File;

public class Main {

    public static boolean deleteDirectory(File path) {
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    deleteDirectory(files[i]);
                } else {
                    files[i].delete();
                }
            }
        }

        return (path.delete());
    }
}

Related

  1. deleteDirectory(File directory)
  2. deleteDirectory(File directory)
  3. deleteDirectory(File path)
  4. deleteDirectory(File path)
  5. deleteDirectory(File path)
  6. deleteDirectory(String directory)
  7. deleteDirectory(String path)
  8. deleteDirectory(String path)
  9. deleteDirectory(final File directory)