File exists in mobile storage or not

File exists in mobile storage or not ? You can search any type of file with the help of this method.

 img_pdf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


// 'str' can be changed here
// 'selected_file' is the name of your file

String str = "Download/" + selected_file;


if (isFilePresent(str)) {
Toast.makeText(mContextpdf, "Yes", Toast.LENGTH_SHORT).show();
} else

Toast.makeText(mContextpdf, "no", Toast.LENGTH_SHORT).show();
}



//method
public boolean isFilePresent(String filename) {

// String str="Download/"+selected_file;
// String path = mContextpdf.getFilesDir().getAbsolutePath() + "/" + filename;
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + filename);
// File file = new File(path);
return file.exists();
}



Thanks
Rahul kumar
9899605742