简体   繁体   English

如何获取存储在资产文件夹中的图像文件的最后修改日期?

[英]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"); getFileDate( “图像/ 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? 以毫秒为单位的时间始终显示为0。是否可以从资产文件夹中存储的图像中获取上次创建的日期? if so then how? 如果是这样,那怎么办?

Please note that the file does exist in the assets folder within a subfolder named images. 请注意 ,该文件确实存在于名为images的子文件夹中的assets文件夹中。 Also i am able to load it into an ImageView but not able to get the last modified date 我也可以将其加载到ImageView中,但无法获取上次修改日期

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. File类也不能用于它。

Files in assets can not be modified either. 资产中的文件也无法修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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