id:Kodakana
Androidアプリ開発部のことを語る

ファイルを ListView に新しい順に並べるのが意外と簡単に行かない。
 String files[] = path.list();
 List<Long> updates = new ArrayList<Long>();
 HashMap<Long, String> lsl = new HashMap<Long, String>();
 for(int index = 0 ; index < files.length; index++){
  File who = new File (path, files[index]);
   if (!who.isDirectory()){
    updates.add(who.lastModified());
    lsl.put(who.lastModified(), files[index]);
   }
 }
 Collections.sort(updates);
 Collections.reverse(updates);
 for (int index = 0; index < updates.size(); index++){
  arayadapter.add(lsl.get(updates.get(index)));
 }
みたいにやると一見(゚д゚)ウマーの様だが、更新日時がミリ秒単位で同じファイルがあるとうまく行かない。