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
 

Latest posts

Trending Posts

Members online

Forum statistics

Threads
963,127
Messages
6,992,711
Members
3,164,980
Latest member
RangelS25