我正在使用它来查看文件是否已存在并获取其时间戳:
File file = new File(getResources().getString(R.string.file_name));
if (file.exists()) {
Date lastModified = new Date(file.lastModified());
}
Run Code Online (Sandbox Code Playgroud)
即使我可以使用Context.fileList()方法看到这个文件确实存在,但上面的代码总是说它没有.
如何获取文件的上次修改日期?
Ebo*_*ike 12
我认为你的问题是file.exists()失败了,修改日期的问题与它无关.
我冒昧地说你正在使用的路径是你的应用程序的本地路径?使用时需要使用绝对路径File.
| 归档时间: |
|
| 查看次数: |
25168 次 |
| 最近记录: |