public static boolean deleteFile(String filePath) throws FileNotFoundException,
IOException {
try {
File file = new File(filePath);
if (!file.isDirectory()) {
file.delete();
}
else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File subfile = new File(filePath+ "//" + filelist[i]);
if (!subfile .isDirectory())
subfile .delete();
else if (subfile .isDirectory())
deleteFile(filePath+ "//" + filelist[i]);
}
file.delete();
}
}
catch (FileNotFoundException e) {
Log.debug("deleteFile() Exception:" + e.getMessage());
}
return true;
}
IOException {
try {
File file = new File(filePath);
if (!file.isDirectory()) {
file.delete();
}
else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File subfile = new File(filePath+ "//" + filelist[i]);
if (!subfile .isDirectory())
subfile .delete();
else if (subfile .isDirectory())
deleteFile(filePath+ "//" + filelist[i]);
}
file.delete();
}
}
catch (FileNotFoundException e) {
Log.debug("deleteFile() Exception:" + e.getMessage());
}
return true;
}