Guest User

Untitled

a guest
Dec 18th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. private ArrayList<PDFDoc> getPDFs()
  2.  
  3. {
  4. ArrayList<PDFDoc> pdfDocs=new ArrayList<>();
  5. //TARGET FOLDER
  6. File downloadsFolder= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
  7.  
  8. PDFDoc pdfDoc;
  9.  
  10. if(downloadsFolder.exists())
  11. {
  12. //GET ALL FILES IN DOWNLOAD FOLDER
  13. File[] files=downloadsFolder.listFiles();
  14.  
  15. //LOOP THRU THOSE FILES GETTING NAME AND URI
  16. for (int i=0;i<files.length;i++)
  17. {
  18. File file=files[i];
  19.  
  20. if(file.getPath().endsWith("pdf"))
  21. {
  22. pdfDoc=new PDFDoc();
  23. pdfDoc.setName(file.getName());
  24. pdfDoc.setPath(file.getAbsolutePath());
  25.  
  26. pdfDocs.add(pdfDoc);
  27. }
  28.  
  29. }
  30. }
  31.  
  32. return pdfDocs;
  33. }
Add Comment
Please, Sign In to add comment