Java tutorial
//package com.java2s; import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { static List<File> listFile = new ArrayList<File>(); static String fileType; public static List<File> searchFileFrom(String rootPath, String type) { listFile.clear(); fileType = type; File rootFile = new File(rootPath); if (rootFile.isDirectory()) { searchDir(rootFile); } return listFile; } private static void searchDir(File dirFile) { File[] files = dirFile.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { if (file.getName().subSequence(0, 1).equals(".") || file.getName().equals("Android") || file.getPath().equalsIgnoreCase("/storage/emulated")) { } else { searchDir(file); } } else { if (file.getName().toLowerCase().contains(fileType.toLowerCase())) { listFile.add(file); } } } } } }