Has i am create sample application using android using File concepts,
Following steps are :
--- 1. I give the parent folder name "default"
--- 2. To find the parent folder to sub folder.
--- 3. List the sub folder file.
--- 4. Delete the Empty the sub folder
i will completed three steps,In the problem is how to find the sub folder are Empty given me one solution ?
sample code :
File filefirst = new File("/storage/sdcard0/Parentfoldername/");
String[] names = filefirst.list();
for (String name : names)
{
if (new File("/storage/sdcard0/Parentfoldername/" + name).isDirectory()) {
File directory = new File("/storage/sdcard0/Parentfoldername/" + name);
//get all the files from a directory
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile())
{
if (directory.isDirectory())
{
String[] children = directory.list();
for (int i = 0; i < children.length; i++)
{
new File(directory, children[i]).delete();
}
}
}
}
}
}
This code like delete the sub_folder inside the file ,that sub_folder are deleted not folder is file but Empty sub_folder is not delete.