Android examples for java.io:File Directory
delete Directory
import android.util.Log; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main{ /**//from w w w . j a va2s . c om * Cleanup a directory. */ static public boolean deleteDirectory(String directoryPath) { File path = new File(directoryPath); return deleteDirectory(path); } static public 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(); } return false; } }