Android examples for java.io:Directory
get Files by extension from a directory
import java.io.File; import java.util.ArrayList; import java.util.List; public class Main{ protected static List<File> getFiles(File dir, String extension) { List<File> files = new ArrayList<File>(); for (File f : dir.listFiles()) { if (f.getName().endsWith(extension)) files.add(f);//w ww . ja v a2 s . co m } return files; } }