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
 

Trending Posts

Forum statistics

Threads
956,347
Messages
6,967,720
Members
3,163,517
Latest member
NameRingtone