how to get last modified date of a file from external storage

  • Thread starter Thread starter Android Central Question
  • Start date Start date
A

Android Central Question

try {
BasicFileAttributes attr = readAttributes(Paths.get(filePath), BasicFileAttributes.class);
// sdf.format(attr.creationTime().toMillis());
Toast.makeText(this, "filePath is111 > " + filePath + "\n"
+ "creationTime is > " + sdf.format(attr.creationTime().toMillis())+ "\n"
+ "lastModifiedTime is > " + sdf.format(attr.lastModifiedTime().toMillis()) + "\n"
+ "lastAccessTime is > " + sdf.format(attr.lastAccessTime().toMillis())
, Toast.LENGTH_SHORT).show();

} catch (IOException e) {
Toast.makeText(this, "IOException is > " + e.toString(), Toast.LENGTH_SHORT).show();
}

------------------------------

when select file from enternal storage is work fine

when select fele from external storage is return current date
 

Members online

Forum statistics

Threads
963,077
Messages
6,992,629
Members
3,164,983
Latest member
whhghjk7788