I'm very new in Java and I'd like to know if there's any way to delete a folder that may contain some files just like "rm -rf directory/" in command line.
Here's what I'm working on.
public static boolean checkUnzippedExistence(String deleteKeyword) {
List<String> foldersList = new ArrayList<String>();
String absPath = Environment.getExternalStorageDirectory().getPath();
File[] files = new File(absPath).listFiles();
boolean existence = false;
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory() && files[i].getName().contains(deleteKeyword)) {
//some method/function to delete
}
}
existence = true;
}
return existence;
}
Thanks in advance.