Tag Archives: open failed

Android has applied for permission and still prompts open failed: eacces (permission denied)

solution

people need to upload the latest file in Android10, declare and dynamically apply for permissions, but it still indicates that the file cannot be opened. To solve this problem, the following steps should be done:

  1. permissions that are requested in the Manifest file

< USES – permission android: name = “android. Permission. WRITE_EXTERNAL_STORAGE”/& gt;
< USES – permission android: name = “android. Permission. READ_INTERNAL_STORAGE”/& gt;

  1. dynamically applies for read file permissions (called in the activity)
private  final int REQUEST_EXTERNAL_STORAGE = 1;
private  String[] PERMISSIONS_STORAGE = {
        Manifest.permission.READ_EXTERNAL_STORAGE,
         Manifest.permission.WRITE_EXTERNAL_STORAGE };
public  void verifyStoragePermissions(Activity activity) {
    // Check if we have write permission
    int permission = ActivityCompat.checkSelfPermission(activity,
            Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permission != PackageManager.PERMISSION_GRANTED) {
        // We don't have permission so prompt the user
        ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
                REQUEST_EXTERNAL_STORAGE);
    }
}
    The new Android10

  1. requires a property
  2. to be declared in the Application

< application
Android: requestLegacyExternalStorage = “true”/& gt;

at this point, you can really read the files in the system.