Java tutorial
//package com.java2s; import java.io.File; import android.os.Environment; import android.util.Log; public class Main { public static boolean deleteDirectory(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); if (!fileName.equals("")) { File path = Environment.getExternalStorageDirectory(); File newPath = new File(path.toString() + fileName); checker.checkDelete(newPath.toString()); if (newPath.isDirectory()) { String[] listfile = newPath.list(); // delete all files within the specified directory and then // delete the directory try { for (int i = 0; i < listfile.length; i++) { File deletedFile = new File(newPath.toString() + "/" + listfile[i].toString()); deletedFile.delete(); } newPath.delete(); Log.i("DirectoryManager deleteDirectory", fileName); status = true; } catch (Exception e) { e.printStackTrace(); status = false; } } else status = false; } else status = false; return status; } }