我正在尝试这个,但它给了我目录的最后修改日期,而不是保存在目录中的文件。请尽快回复。
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);