2

How to show a list of all PDF files stored in assets folder or Raw folder in resource folder

amrita
  • 61
  • 2
  • 9

1 Answers1

1

create a file object with your path to raw folder then call

file.listFiles();

this will return list of all files then filter these files with .pdf extension

// edited

AssetManager assetManager = mContext.getAssets();
String[] arrData = assetManager.list("pdfFolder");//name of your directory as assets/pdfFolder/abc.pdf
List<String> pdfList = new ArrayList<String>();
int size =  arrData.length();
for(int i = 0;i<size;i++)
{
   if(arrData[i].contains(".pdf"))

   {
     pdfList.add(arrData[i]); 
    }
}
vipin
  • 2,851
  • 4
  • 18
  • 32
  • http://android.stackexchange.com/questions/2188/best-way-to-read-programming-technical-math-pdfs-on-android-device – vipin Apr 12 '12 at 13:08
  • stackoverflow.com/questions/3831019/… am not getting what path should i give? as i want read that PDF file which is listed from assets folder?? – amrita Apr 12 '12 at 14:07
  • file:///android_asset/pdfFolder – vipin Apr 13 '12 at 05:00
  • it is not working :( I had written like this: File file = new File("file:///android_asset/raw/"+filename); – amrita Apr 13 '12 at 07:34
  • do one thing create a new question for this – vipin Apr 13 '12 at 07:35
  • i had created with "Read .PDF/.TXT files in android" – amrita Apr 13 '12 at 07:37
  • AssetFileDescriptor descriptor = getAssets().openFd("myfile.txt"); FileReader reader = new FileReader(descriptor.getFileDescriptor()); – vipin Apr 13 '12 at 07:37
  • i think we should move this discussion to chat – vipin Apr 13 '12 at 07:40
  • ohhhh you dont have enough rep so we cant talk on stack overflow give me request on my mail id which is in my stack overflow profile – vipin Apr 13 '12 at 07:57