FileNotFoundException (permission denied) when trying to write file to sdcard in Android FileNotFoundException (permission denied) when trying to write file to sdcard in Android android android

FileNotFoundException (permission denied) when trying to write file to sdcard in Android


  1. Everything works fine with writing files to private folder on sdcard

Beginning with Android 4.4, these permissions are not required if you're reading or writing only files that are private to your app. For more information, see saving files that are app-private.

  1. FileNotFoundException (permission denied) when trying to write file to sdcard in Android

As you are trying to write the file in emulator having API 23(Marshmallow), You need to Request WRITE_EXTERNAL_STORAGE permission at runtime also. Check this and this for more detail.