get Files From Local Folder - Android java.io

Android examples for java.io:Folder

Description

get Files From Local Folder

Demo Code

import android.os.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

public class Main{

    public static List<File> getFilesFromLocalFolder(File folder) {
        List<File> filesList = new ArrayList<>();
        if (!folder.isDirectory()) {
            return filesList;
        }/*from   w  ww  .j a  v a 2  s .c om*/
        if (!folder.exists()) {
            folder.mkdirs();
        }
        File[] filesArray = folder.listFiles();
        filesList.addAll(Arrays.asList(filesArray));
        return filesList;
    }

}

Related Tutorials