I am trying o delete an entire directory. I have searched and I am using this code and I am able to delete everything in the directory, but the directory still remains. Here is the exact code I have just in case I am missing something.
public boolean DeletePoint(String JobName, String PointName){
//Delete actual contents and file
File folder = new File(rootSaveFolder "/" + PointName+"/");
boolean returnBool = false;
try{
returnBool = deleteDirectory(folder);
folder.delete();
} catch (SecurityException e){
e.printStackTrace();
}
}
static public boolean deleteDirectory(File path) {
if( path.exists() ) {
File[] files = path.listFiles();
if (files == null) {
return true;
}
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
return(path.delete());
}
The string for the file I am deleting is: /mnt/sdcard/test/gg/
I have tried it with out the final '/' and that didn't work either.