开发者

how to set a file's lastModifiedDate?

开发者 https://www.devze.com 2023-02-28 09:27 出处:网络
For my app I want to keep track of which files have been accessed most recently (for cache management: files used least are first to go out).

For my app I want to keep track of which files have been accessed most recently (for cache management: files used least are first to go out).

Now Android doesn't appear to have a last accessed date function for files, so I'm looking at the next best thing: file.lastModifiedDate(). That gives me the last modified date, which is effectively the creation date.

But when acces开发者_Go百科sing the file I'd like to set this value to the current time. Like Linux's touch command. How can I do this, without actually modifying the file?


This should work:

http://www.java-examples.com/set-last-modified-time-file-or-directory

0

精彩评论

暂无评论...
验证码 换一张
取 消