Java tutorial
//package com.java2s; import android.text.TextUtils; import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getCatgFolderContent(String folderDir, String catg) { List<String> allFiles = new ArrayList<>(); List<String> catgFiles = new ArrayList<>(); allFiles = getFolderContent(folderDir); for (String str : allFiles) { if (!TextUtils.isEmpty(str) && str.contains(catg)) catgFiles.add(str); } return catgFiles; } public static List<String> getFolderContent(String folderDir) { File file = new File(folderDir); List<String> filesPath = new ArrayList<>(); if (!file.exists()) { } else { for (File f : file.listFiles()) { if (f.isFile()) { filesPath.add(f.getPath()); } } } return filesPath; } }