I’m using this to see if a file already exists and get its timestamp:
File file = new File(getResources().getString(R.string.file_name));
if (file.exists()) {
Date lastModified = new Date(file.lastModified());
}
Even though I can see that this file does indeed exist using the Context.fileList() method, the code above always says it doesn’t.
How can I get a file’s last modified date?
I take it your problem is that
file.exists()fails, the issue with the modified date has nothing to do with it.I’d venture that the path you’re using is local to your application? You’ll need to use absolute paths when using
File.