Android APIv29 FileNotFoundException EACCES (Permission denied) Android APIv29 FileNotFoundException EACCES (Permission denied) android android

Android APIv29 FileNotFoundException EACCES (Permission denied)


Starting with Android 11 the storage permission is getting revoked and developers would need to consider alternative ways of accessing the storage they need either through SAF or Media Store. For the time being, you can carry on using what you’re using by adding the following in your manifest within the application tags:

android:requestLegacyExternalStorage="true"

You might want to consider changing your minSDK to 19 and use getExternalFilesDir() to get a path that doesn’t require any permissions.


When your app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps.

    val path = getExternalFilesDir(Environment.DIRECTORY_PICTURES.toString() +     File.separator + "Output Folder")    val file = File(getExternalFilesDir(null), "filename.jpg")

For more details visit Docs


With Android version 10 (API level 29) the concept of scoped storage is introduced. According to Docs- "To give users more control over their files and to limit file clutter, apps that target Android 10 (API level 29) and higher are given scoped access into external storage, or scoped storage, by default. Such apps have access only to the app-specific directory on external storage, as well as specific types of media that the app has created."

for Android version 10, you have option to opt-out scoped storage by adding android:requestLegacyExternalStorage="true" in AndroidManifest.xml within the application tags

This is a temporary solution and will work only for android version 10 and not above it. Also make sure you ask run-time permission for read/write external storage.