是否有可能恢复一个Android文件的最后修改日期?有可能、日期、文件、Android

2023-09-09 21:04:15 作者:稳握江山权

我正在为我们的软件,消除尚未一个多月应用于所有的图像文件的清除功能。要做到这一点,我检查两件事情:

I'm writing a purge function for our software that removes all image files that haven't been used in over a month. To do this, I am checking two things:

文件的最后修改日期,显示最近浏览过的文件的数据库上查询。

查询比文件检查要慢得多。所以,我想最好是能够重置失败的第一次检查所有文件的最后修改日期,但通过第二道,这样(例如)的古老的,但经常使用的文件列表不逐步增加处理管理系统的负荷。

The query is much slower than the file check. So I would ideally like to be able to reset the last modified date on any files that fail the first check, but pass the second, so that (for example) a list of venerable but often-used files aren't gradually increasing the processing load of the management system.

有没有办法做到这一点不诉诸原油的东西(甚至可能更慢),就像每个文件重命名为一个临时的标签,然后自己?

Is there a way to do this without recourse to something crude (and possibly even slower), like renaming each file to a temporary label, then itself?

推荐答案

setLastModified()是在任何Java 文件的标准方法对象,您可以用它来更新此值。

setLastModified() is a standard method on any Java File object that you can use to update this value.

SDK文档。