0

I tryed many solutions in the forum but they do not seem to work. I need to create a pdf in my phone (Environment.getExternalStorageState() +File.separator +"Try" +File.separator +"FirstPdf.pdf";) but i have an exception. I use verifyStoragePermissions(this) and <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> in the manifest.

SkyEeros
  • 1
  • 2

2 Answers2

0

Replace Environment.getExternalStorageState() to Environment.getExternalStorageDirectory().

diogojme
  • 2,309
  • 1
  • 19
  • 25
0

Try this

File file = new File(Environment.getExternalStorageDirectory() +File.separator +"Try" +File.separator +"FirstPdf.pdf");\
// here your logic for write pdf file

Note:

you are trying getExternalStorageState() and it will Returns the current state of the primary shared/external storage media.

Refer: External storage state

Pramod Waghmare
  • 1,273
  • 13
  • 21