如何从文件夹中获取文件的所有文件的创建日期,并在TextView中显示,在gridview android持有人.创建日



我正在尝试这个,但它给了我目录的最后修改日期,而不是保存在目录中的文件。请尽快回复。

File dir = new File(Environment.getExternalStorageDirectory().toString() + "/Android/data/" + getContext().getPackageName() + "/Media");

Date lastModified = new Date(dir.lastModified());
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String formattedDateString = formatter.format(lastModified);

holder.textDate.setText(formattedDateString);

把我的代码改成路径是我的文件

的路径
File dir = new File("");
dir= new File(path);
Date lastModified = new Date(dir.lastModified());
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String formattedDateString = formatter.format(lastModified);

holder.textDate.setText(formattedDateString);