Android Utililty Methods Folder File List

List of utility methods to do Folder File List


The list of methods to do Folder File List are organized into topic(s).


File[]ListFiles(File dir, FilenameFilter filter)
Lists the files in a specific directory that satisfy the filter.
File[] files = null;
if (dir != null && dir.isDirectory()) {
    files = dir.listFiles(filter);
return files;
ListgetAllFilesAndFolders(File root, boolean containEmpty)
Get all files and directories under the specified fold.
List<File> files = new ArrayList<File>();
if (containEmpty || (!containEmpty && !isEmpty(root))) {
if (root.isDirectory()) {
    File[] fs = root.listFiles();
    for (File f : fs) {
String[]getFileNames(String dirPath)
get File Names
return getFileNames(dirPath, null);
String[]getFileNames(String dirPath, FilenameFilter fileNameFilter)
get File Names
String fileNames[] = null;
File dir = new File(dirPath);
if (dir.isDirectory()) {
    if (fileNameFilter != null) {
        fileNames = dir.list(fileNameFilter);
    } else {
        fileNames = dir.list();
return fileNames;
voidgetFiles(File dir, List outList)
Recursively get the list of the files in a given dir and add it to the list passed in the second argument.
if (dir == null) {
try {
    if (!dir.isDirectory()) {
    File[] list = dir.listFiles();
String[]listFiles(String fileName)
list Files
return listFiles(new File(fileName));
booleanpathContains(String root, String child)
Verifies that a path, child, is inside of a parent path root
Path childPath = Paths.get(Files.simplifyPath(child));
Path rootPath = Paths.get(root);
return childPath.startsWith(rootPath);
ListlistFile(File file)
list File
if (file.isDirectory()) {
    File[] files = file.listFiles();
    for (File f : files) {
} else {
return fileNames;
String[]listFiles(File file)
list Files
List files = new ArrayList();
File[] fileArray = file.listFiles();
for (int i = 0; i < fileArray.length; i++) {
    if (fileArray[i].isFile()) {
return (String[]) files.toArray(new String[0]);
ListgetFileList(File f)
get File List
List<File> list = new ArrayList<File>();
for (File tmp : f.listFiles()) {
return list;