Home > DeveloperSection > Forums > How to use Choose file in android without using browse?
Pooja Malohtra
Pooja Malohtra

Total Post:47

Posted on    November-16-2014 10:50 PM

 Android Java  File 

 1 Reply(s)
 848  View(s)
Rate this:

I have an application on android phone. People will download pdf file before using my app, and the pdf file will be saved in a certain folder.

I know the absolute path of the folder, but I don't know the name of the new pdf file people download, so I can't get the absolute path of the pdf apparently.

Is there any method to choose the file by using maybe the file type? (Because I am sure that there is only one pdf file in that folder.) By the way, I don't want to choose file by browse.

Here is the stupid method I used before, but it can't match my demand anymore.

public static final String file_name = "//sdcard//Download//test.pdf";

File myFile = new File(file_name);

Any easy way to solve the problem? Thanks for your help sincerely.

Tom Cruser
Tom Cruser

Total Post:28

Posted on    November-17-2014 3:02 AM

Below method will give all the PDF files in Download folder.

String path = Environment.getExternalStorageDirectory().toString()+"/Download";

File f = new File(path);       

File files[] = f.listFiles();  

for (File f : files)


      String fullPath = f.getAbsolutePath();

      int dot = fullPath.lastIndexOf(".");

      String ext = fullPath.substring(dot + 1);



        //do something with f here



Don't want to miss updates? Please click the below button!

Follow MindStick