DeathRs
DeathRs

Reputation: 1120

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

Upvotes: 2

Views: 1041

Answers (1)

greenapps
greenapps

Reputation: 11224

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.

Upvotes: 3

Related Questions