-1

How can i get the time of creation of the files that are in a folder and then put in them in a string array?

This is the code use for read the files of the folder and then put them in a string array:final

File carpeta = new File("/storage/emulated/0/Android/data/cc.openframeworks.androidMultiOFActivitiesExample/files/xml");

listarFicherosPorCarpeta(carpeta);

  List<String> list = new ArrayList<String>();

    public void listarFicherosPorCarpeta(final File carpeta) {
        for (final File ficheroEntrada: carpeta.listFiles()) {

            if (ficheroEntrada.isDirectory()) {
                listarFicherosPorCarpeta(ficheroEntrada);
            } else {
                System.out.println(ficheroEntrada.getName());
                    list.add(ficheroEntrada.getName());

            }
        }
Zhubei Federer
  • 1,274
  • 2
  • 10
  • 27
full rusian
  • 37
  • 1
  • 7

2 Answers2

0
File file = new File(filePath);
Date lastModDate = new Date(file.lastModified());
Log.i("File last modified @ : "+ lastModDate.toString());

Credit to Android: How to get a file's creation date?

Elias Fazel
  • 2,093
  • 16
  • 20
0

If you are on API 26 or above, use BasicFileAttributes.

BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
long creationTime = attr.creationTime().toMillis();
Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126