Delete files and directories, even if non-empty.
if (dir == null || !dir.exists()) return false;
File contents[] = dir.listFiles();
if (contents != null) {
for (int i = 0; i < contents.length; i++) {
if (contents[i].isFile()) {
if (!contents[i].delete()) {
return false;
}
} else {
if (!fullyDelete(contents[i])) {
return false;
}
}
}
}
return dir.delete();