我正在尝试检查应用程序内部存储中的子目录中是否存在zip:
File file = this.getApplicationContext().getFileStreamPath(this.getFilesDir().getAbsolutePath() + "/thesubdirectory/the.zip"; if(file.exists()) { Log.e(this.class.getName(),"file exists"); }
这是抛出java.lang.IllegalArgumentException:文件/data/data/my.package.name/files/thesubdirectory/the.zip包含路径分隔符.
为什么会这样?我认为这是你应该检查文件是否存在的方式.
解决方法
file.exists是.但getFileStreamPath无法获取路径,需要在该目录中获取文件名.试试这个:
File file = new File(this.getFilesDir().getAbsolutePath() + "/thesubdirectory/the.zip");