Home > Mobile >  Android dynamic application storage access still permission denied
Android dynamic application storage access still permission denied

Time:11-22

I run in the simulator is normal, prove that the code is no problem,

Dynamic application code below,
Try {
String [] PERMISSIONS_STORAGE={
"Android. Permission. READ_EXTERNAL_STORAGE" and "android. Permission. WRITE_EXTERNAL_STORAGE"
};
Int permission=ActivityCompat. CheckSelfPermission (activity, "android. Permission. WRITE_EXTERNAL_STORAGE"); If (permission!=PackageManager. PERMISSION_GRANTED) {ActivityCompat. RequestPermissions (activity, PERMISSIONS_STORAGE REQUEST_EXTERNAL_STORAGE); }} the catch (Exception e) {the d (TAG, "verifyStoragePermissions: access failure" + e); }
An error as below
File: Java. IO. FileNotFoundException:/storage/emulated/0/1. TXT: open failed: EACCES (Permission denied)

I also tried to phone open storage access permissions manually, or not

I use the android studio3, plus the android injected. TestOnly=false

Manifests the china-canada

Hope to be able to solve, thank you for your

CodePudding user response:

The
refer to the original poster weixin_41221178 response:
I run in the simulator is normal, prove that the code is no problem,

Dynamic application code below,
Try {
String [] PERMISSIONS_STORAGE={
"Android. Permission. READ_EXTERNAL_STORAGE" and "android. Permission. WRITE_EXTERNAL_STORAGE"
};
Int permission=ActivityCompat. CheckSelfPermission (activity, "android. Permission. WRITE_EXTERNAL_STORAGE"); If (permission!=PackageManager. PERMISSION_GRANTED) {ActivityCompat. RequestPermissions (activity, PERMISSIONS_STORAGE REQUEST_EXTERNAL_STORAGE); }} the catch (Exception e) {the d (TAG, "verifyStoragePermissions: access failure" + e); }
An error as below
File: Java. IO. FileNotFoundException:/storage/emulated/0/1. TXT: open failed: EACCES (Permission denied)

I also tried to phone open storage access permissions manually, or not

I use the android studio3, plus the android injected. TestOnly=false

Manifests the china-canada

Hope to be able to solve, thank you for your

Done, my android 10, so add android: requestLegacyExternalStorage="true"

CodePudding user response:

Give you said a good dynamic application permissions repository at https://github.com/googlesamples/easypermissions

CodePudding user response:

Thank you, I also am this problem,

CodePudding user response:

Android10 can also through the android: requestLegacyExternalStorage="true", do a compatible operation, after Android11, this method also is invalid, try not to in the sd card read and write operations, should use the sand box, namely data/data/package name and sdcard/Andrdoid/data/package name directory file read and write operations, Android11 behavior change: https://developer.android.google.cn/preview/behavior-changes-all?

CodePudding user response:

Behind the Android permission will be more and more strict
  • Related