Android APIv29 FileNotFoundException EACCES (Permission denied)

99封情书 提交于 2019-12-04 15:50:19

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.

may be this can help you there are changes in android level 29 https://developer.android.com/about/versions/10/behavior-changes-10

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

you need request permission Manifest.permission.WRITE_EXTERNAL_STORAGE again.

before 9.0,you request only Manifest.permission.READ_EXTERNAL_STORAGE and you will get also Manifest.permission.WRITE_EXTERNAL_STORAGE,but begin with 9.0,you can get only one permission that you have requseted.

Forgive my poor english.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!