Reputation: 412
I am saving the images in an app-specific folder and when i am trying to fetch the list of all the images of that folder and saving them in an array, the order of images which i am getting is random. I want the list of images in the order they are created i.e the newest one should come on top. Is there any function to achieve that. I am using this code to get the list of all files and storing them in an array.
File[] listFile = downloadDir.listFiles();
Upvotes: 0
Views: 171
Reputation: 196
You can always sort this Array by calling the sort method with a comparator that will sort the files based on their creation date. A way this could be achieved is explained here: Best way to list files in Java, sorted by Date Modified?
Upvotes: 1