How to delete folder(contain some folder and file) from internal storage? Folder have some below tree.
folder
|_________ C2 (folder)
|________1 (folder)
|________1.gif
|________2.gif
|________3.gif
|________4.gif
|________2 (folder)
|________1.gif
|________2.gif
|________3.gif
|________4.gif
|________3 (folder)
|________1.gif
|________2.gif
|________3.gif
|________4.gif
|________4 (folder)
|________1.gif
|________2.gif
|________3.gif
|________4.gif
|________5 (folder)
|________1.gif
|________2.gif
|________3.gif
|________4.gif
|_________ C2.xml (file)
I want to delete folder and containing all files
fil.delete();
System.out.println("boolean =>" + fil.delete());
but above code shows false. Please help.
Check this out.
public void deleteRecursive(File fileOrDirectory) {
if (fileOrDirectory.isDirectory()) {
for (File child : fileOrDirectory.listFiles()) {
deleteRecursive(child);
}
}
fileOrDirectory.delete();
}
for explaination How to delete a whole folder and content?