1
我们如何检查给定的文件是否存在于Android Filesystem中而不使用File inputstream.because,因为我只想检查给定路径上是否存在该文件。检查给定的文件是否存在于此路径中,或不在Android文件系统中?
我们如何检查给定的文件是否存在于Android Filesystem中而不使用File inputstream.because,因为我只想检查给定路径上是否存在该文件。检查给定的文件是否存在于此路径中,或不在Android文件系统中?
File myFile = new File("/path/to/file");
if (myFile.isFile()) {
...
}
如果您已经创建使用openFileOutput
方法的文件,则该作品
File mFile = new File(getBaseContext().getFilesDir(),FileName);
if (mFile.exists())
{
//File is Exits.
}
else
{
//File is not Exits.
}
希望这有助于
由于格雷厄姆的Borland – Mak
myFile.exists()是redunant到ISFILE – berlindev
@Animated钟:所以,谢谢。现在修复。 –