Search code examples
androidandroid-layoutpdfandroid-intentfile-browser

Getting path of a pdf in android


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


Solution

  • 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