Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ArrayList<PDFDoc> getPDFs()
- {
- ArrayList<PDFDoc> pdfDocs=new ArrayList<>();
- //TARGET FOLDER
- File downloadsFolder= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
- PDFDoc pdfDoc;
- if(downloadsFolder.exists())
- {
- //GET ALL FILES IN DOWNLOAD FOLDER
- File[] files=downloadsFolder.listFiles();
- //LOOP THRU THOSE FILES GETTING NAME AND URI
- for (int i=0;i<files.length;i++)
- {
- File file=files[i];
- if(file.getPath().endsWith("pdf"))
- {
- pdfDoc=new PDFDoc();
- pdfDoc.setName(file.getName());
- pdfDoc.setPath(file.getAbsolutePath());
- pdfDocs.add(pdfDoc);
- }
- }
- }
- return pdfDocs;
- }
Add Comment
Please, Sign In to add comment