简体   繁体   中英

How do i get the last modified date of image files stored in assets folder?

private void getFileDate(String path) {
    File file = new File(path);
    Date dt = new Date(); 
    dt.setTime(file.lastModified());

    Toast.makeText(this, file.lastModified()+"_"+file.getAbsolutePath().toString(),Toast.LENGTH_LONG).show();
}

When i call

getFileDate("images/ironman.jpg");

The time in milis is always shown as 0. Is it possible to get last created date from images stored in the assets folder? if so then how?

Please note that the file does exist in the assets folder within a subfolder named images. Also i am able to load it into an ImageView but not able to get the last modified date

There is no such thing as last modified date for files in assets.
There also is no creation date.
The only thing you can determine is file size.
The assets is not a file system but a resource.
The File class can not be used for it too.

Files in assets can not be modified either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM