/**
* Getting files from Folder(Time Sorting by Modify time)
* @param path
* @return
*/
private List getFileSort(String path) {
List list = getFiles(path, new ArrayList());
if (list != null && list.size() > 0) {
Collections.sort(list, new Comparator() {
public int compare(File file, File newFile) {
if (file.lastModified() < newFile.lastModified()) {
return 1;
} else if (file.lastModified() == newFile.lastModified()) {
return 0;
} else {
return -1;
}
}
});
}
return list;
}
/**
* Get all the file from folders(img/{drivesid})
*
* @param realpath
* @param files
* @return
*/
private List getFiles(String realpath, List files) {
File realFile = new File(realpath);
if (realFile.isDirectory()) {
File[] subfiles = realFile.listFiles();
for (File file : subfiles) {
if (file.isDirectory()) {
getFiles(file.getAbsolutePath(), files);
} else {
files.add(file);
}
}
}
return files;
}