Android Utililty Methods Directory Content Get

List of utility methods to do Directory Content Get

Description

The list of methods to do Directory Content Get are organized into topic(s).

Method

ListgetFileInDirectory(File f)
get File In Directory
List<File> list = getFileList(f);
boolean check = true;
while (check) {
    check = false;
    List<File> listtmp = list;
    List<File> listtmp2 = new ArrayList<File>();
    ;
    for (File checktmp : listtmp) {
...
ListgetFiles(File parentDir)
get Files
List<File> fileList = new ArrayList<>();
File[] files = parentDir.listFiles();
if (files != null) {
    for (File file : files) {
        if (file.isFile()) {
            fileList.add(file);
return fileList;
voidgetFilesAndSubFolderFiles(List fileList, File rootDir)
get Files And Sub Folder Files
if (fileList != null) {
    File[] files = rootDir.listFiles();
    if (files != null) {
        for (File file : files) {
            if (file.isFile()) {
                fileList.add(file);
            } else if (file.isDirectory()) {
                getFilesAndSubFolderFiles(fileList, file);
...
String[]listDirs(File file)
list Dirs
List dirs = new ArrayList();
File[] fileArray = file.listFiles();
for (int i = 0; i < fileArray.length; i++) {
    if (fileArray[i].isDirectory()) {
        dirs.add(fileArray[i].getName());
return (String[]) dirs.toArray(new String[0]);
...
String[]listDirs(String fileName)
list Dirs
return listDirs(new File(fileName));
String[]listFile(File dir)
list File
String absolutPath = dir.getAbsolutePath();
String[] paths = dir.list();
String[] files = new String[paths.length];
for (int i = 0; i < paths.length; i++) {
    files[i] = absolutPath + "/" + paths[i];
return files;
ListlistFiles(File dir)
list Files
List<File> list = new ArrayList<File>();
if (dir.exists()) {
    for (File f : dir.listFiles()) {
        if (f.isFile()) {
            list.add(f);
return list;
File[]listFiles(File rootDir, final String... sufix)
list Files
return rootDir.listFiles(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
        for (String s : sufix) {
            if (name.toLowerCase().endsWith(s.toLowerCase())) {
                return true;
        return false;
});
ArrayListgetFileList(String path)
get File List
ArrayList<String> fileList = new ArrayList<String>();
File dir = new File(path);
File[] files = dir.listFiles();
if (files == null)
    return null;
for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory()) {
        getFileList(files[i].getAbsolutePath());
...
File[]listFilesByDirectory(String directoryPath, boolean isOnlyFile)
list Files By Directory
File dir = new File(directoryPath);
if (!dir.exists()) {
    return null;
File[] files = null;
if (isOnlyFile) {
    files = dir.listFiles(new FileFilter() {
        @Override
...