Search in this way..it is fast and efficient than your searching file..
private void checkForPdf(File file) {
try {
if (file.exists()) {
File[] listFiles = file.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return filename.toLowerCase().endsWith(".pdf");
}
});
for (File file2 : listFiles) {
//here you will get all pdf files..
}
}
} catch (Exception e) {
}
}