How to check if a folder is empty
if (file.isDirectory()) {
String[] files = file.list();
if (files.length == 0) {
//directory is empty
}
}
if you have the path, you can make a File object check for entries (using file.isDirectory() and file.list())
File directory = new File("/path/to/folder");
File[] contents = directory.listFiles();
// the directory file is not really a directory..
if (contents == null) {
}
// Folder is empty
else if (contents.length == 0) {
}
// Folder contains files
else {
}