You can copy these (these) pdf files to the resources folder, so your files will be part of your application and cannot be accessed from the outside, and you can also treat them like regular files (i.e. open with any pdf viewer in your case). Whenever you want to access the context file, you can call context.getAssets() .
We hope this information helps.
Update: Here is the code that I use to open the file in the download directory, this code can open the PDF file in any compatible PDF reader, if it is installed on the phone, tested using Adobe Reader. To run the code, you need the URI of the pdf file in the resource folder.
String fileName = pdfUrl.substring(pdfUrl.lastIndexOf("/")); Log.i("fileName", "" + fileName); File file = new File("/sdcard/download" + fileName); // File file = new // File("/sdcard/download/airtel_latest000.mp3"); Intent intent; if (file.exists()) { Uri path = Uri.fromFile(file); intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); downloaded = true; } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(pdfUrl)); downloaded = false; } try { startActivityForResult(intent, 5); } catch (ActivityNotFoundException e) { Toast.makeText(this, "No Application Available to View PDF", Toast.LENGTH_SHORT).show(); }
source share