Android File Delete deleteFolderFile(String filePath, boolean deleteThisPath)

Here you can find the source of deleteFolderFile(String filePath, boolean deleteThisPath)

Description

delete Folder File

Declaration

public static void deleteFolderFile(String filePath,
        boolean deleteThisPath) throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.IOException;

import android.text.TextUtils;

public class Main {

    public static void deleteFolderFile(String filePath,
            boolean deleteThisPath) throws IOException {
        if (!TextUtils.isEmpty(filePath)) {
            File file = new File(filePath);

            if (file.isDirectory()) {
                File files[] = file.listFiles();
                for (int i = 0; i < files.length; i++) {
                    deleteFolderFile(files[i].getAbsolutePath(), true);
                }// ww w  . j  a  v  a  2 s.  co m
            }
            if (deleteThisPath) {
                if (!file.isDirectory()) {
                    file.delete();
                } else {
                    if (file.listFiles().length == 0) {
                        file.delete();
                    }
                }
            }
        }
    }
}

Related

  1. recursiveDelete(File path)
  2. removeableFile(File folder, String fileName)
  3. renameFile(String strSrc, String strDest, boolean deleteIfExist)
  4. safelyDeleteFile(File filePath)
  5. safelyDeleteFile(String filePath)
  6. deleteFile(File f)
  7. deleteFile(File file)
  8. deleteFile(String filePath)
  9. delete(File file)