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

Uncategorized
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

Sharing is caring!

Leave a Reply