1

Friends I am trying to get path of the pdf's for my app. Suppose there are n number of pdf's in your android phone(may be in root dir or sdcard) then how could you get there path programmatically ? Could some one please suggest me some hints ?

Thanks in Advance

Karan

1

3 Answers 3

1
File images = Environment.getExternalStorageDirectory();
imagelist = images.listFiles(new FilenameFilter()
{
public boolean accept(File dir, String name)
{
return ((name.endsWith(".pdf")));
}
});
pdflist = new String[imagelist.length];
for(int i = 0;i<imagelist.length;i++)
{
pdflist[i] = imagelist[i].getName();
}

also see this link Assistance required for scanning the .mp3 files in sdcard

3
  • hey man one thing it does scans the pdf bt nt all the pdf's in the phone ...like if some pdf is dere in some other folders then wht ? Jul 24, 2012 at 9:30
  • use the path of the phone you have to search path of phone and then all the work will be done by the code ok and just use google for getting path of phone thats it.
    – Nitin
    Jul 24, 2012 at 9:35
  • i was able to get them by recursively search the items ....like see this link stackoverflow.com/questions/2056221/… Jul 24, 2012 at 10:05
0

For SD Card check

    if (android.os.Environment.getExternalStorageState().equals(
            android.os.Environment.MEDIA_MOUNTED)) {
         File f = new File(Environment.getExternalStorageDirectory());

         File[] files = f.listFiles();
         File file;
         for (int i = 0; i < files.length; i++) {
                file = files[i];
         }
    }

    //For Internal Memory

    else {
            /* save the folder in internal memory of phone */

        File f = new File("/data/data/com.your.package/");
        File[] files = f.listFiles();
    }
0

I was able to get them by recursively searching the items ....

Recursively list files in Java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.