Android: how to get a directory list ordered by name or by date descending?

后端 未结 9 703
轮回少年
轮回少年 2020-12-30 09:48

I\'m able to do this:

    File images = new File(path);  
    File[] imageList = images.listFiles(new FilenameFilter(){  
        public boolean accept(File          


        
9条回答
  •  甜味超标
    2020-12-30 10:42

    If you prefer brevity:

    File[] files = folder.listFiles();
    Arrays.sort(files, (a, b) -> Long.compare(b.lastModified(), a.lastModified()));
    

提交回复
热议问题