1

I want to open a pdf file from the assets folder by clicking a button. Tried the below code but it's not working.

 btn_help.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String uriPath = "file:///android_asset/Guide.pdf";
                        Uri uri = Uri.parse(uriPath);
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setDataAndType(uri, "application/pdf");
                        startActivity(intent);


                    }
                });
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Malhotra
  • 221
  • 3
  • 13
  • 1
    You should use a content provider dat can serve files from assets. It has been published on github and is named AssetsProvider. Hope that is enough for you to find the beast. – blackapps Jun 11 '21 at 13:37
  • https://stackoverflow.com/questions/29477209/android-sending-image-from-assets-folder-using-content-provider – blackapps Jun 11 '21 at 13:42
  • @blackapps Please help me to call assetprovider from my activity. I used like below but it's not working. new AssetsProvider().openAssetFile(Uri.parse("file:///android_asset/eDVIRGuide.pdf"),null); – Malhotra Jun 12 '21 at 14:15

1 Answers1

0

I believe you can use PDF Viewer library .

Through this library you can use pdfView.fromAsset() builder.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
MustafaKhaled
  • 1,343
  • 9
  • 25