I use this code to delete all files:
File root = new File(\"root path\");
File[] Files = root.listFiles();
if(Files != null) {
int j;
for(j = 0; j < F
This code works for me. "imagesFolder" has some files and folders which in turn has files.
if (imagesFolder.isDirectory())
{
String[] children = imagesFolder.list(); //Children=files+folders
for (int i = 0; i < children.length; i++)
{
File file=new File(imagesFolder, children[i]);
if(file.isDirectory())
{
String[] grandChildren = file.list(); //grandChildren=files in a folder
for (int j = 0; j < grandChildren.length; j++)
new File(file, grandChildren[j]).delete();
file.delete(); //Delete the folder as well
}
else
file.delete();
}
}