Requesting and allowing WRITE_EXTERNAL_STORAGE permission at runtime has no effects on the current session

后端 未结 3 1339
花落未央
花落未央 2020-12-13 04:52

this is regarding the new model of runtime permissions introduced in Android Marshmallow when requesting Manifest.permission.WRITE_EXTERNAL_STORAGE permission.<

3条回答
  •  孤街浪徒
    2020-12-13 05:03

    http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE:

    Starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by getExternalFilesDir(String) and getExternalCacheDir().

    Runtime permissions start at API level 23, obviously above 19, so the permission is not required anymore unless you're accessing the data outside of the folder pointed by getExternalFilesDir(). Therefore, I believe this is a bug only present when testing on an emulator.

    On targets below level 19, which don't support requesting permission at runtime, just claim the permission in manifest and it will work.

提交回复
热议问题