0

I checked many times but everyone asked how to open and read these files. But I just want to choose a file from my phone's storage and share it.

I tried using the following code

void sendIntent5() {
        Intent intent = new Intent(Intent.ACTION_SEND);
          String Pathholder = intent.getData().getPath();
        Uri myUri = Uri.parse(Pathholder);
        intent.setDataAndType(myUri, "application/pdf");
        PackageManager pm = this.getPackageManager();
        if (intent.resolveActivity(pm) != null) {
            startActivity(intent);
        }

    }

But I only got the following error : java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getPath()' on a null object reference

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

0 Answers0