Mak
Mak

Reputation: 1063

check that given file is present on this path or not in Android Filesystem?

How can we check the given file is present in Android Filesystem or not without using File inputstream.because I only want to check the existence of the file on the given path.

Upvotes: 1

Views: 128

Answers (2)

Sreeram
Sreeram

Reputation: 3258

If you have created a file using openFileOutput method then this works

File mFile = new File(getBaseContext().getFilesDir(),FileName);
if (mFile.exists() )
{
   //File is Exits.

}
else
{
//File is not Exits.
}

hope this helps

Upvotes: 0

Graham Borland
Graham Borland

Reputation: 60681

File myFile = new File("/path/to/file");
if (myFile.isFile()) {
    ...
}

Upvotes: 1

Related Questions