Here you can find the source of deleteFolderFile(String filePath, boolean deleteThisPath)
public static void deleteFolderFile(String filePath, boolean deleteThisPath) throws IOException
//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(); } } } } } }