java.io.IOException: Permission denied cannot create file

As in the Android Documentation, you need to write to the external storage, you must request the WRITE_EXTERNAL_STORAGE permission in your manifest file:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   ...
</manifest>

If you use API 23 (Marshmallow) and above, you need to Requesting Permissions at Run Time because it's a Dangerous Permission.


If your target api level is >=29 or you are using android 10 then please add following line in your app's manifest file in application tag

android:requestLegacyExternalStorage="true"

Tags:

Android