I'm trying to check whether a zip exists in a subdirectory in the application's internal storage:
File file = this.getApplicationContext().getFileStreamPath(this.getFilesDir().getAbsolutePath() + "/thesubdirectory/the.zip";
if(file.exists()) {
Log.e(this.class.getName(), "file exists");
}
This is throwing a java.lang.IllegalArgumentException: File /data/data/my.package.name/files/thesubdirectory/the.zip contains a path separator
.
Why is this happening? I thought this was the way you should check whether a file exists.
file.exists is. But getFileStreamPath can't take a path, it needs to take a filename in that directory. Try this:
File file = new File(this.getFilesDir().getAbsolutePath() + "/thesubdirectory/the.zip");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With