Home - VaibhavShitole1303/error_Android_vaibhav GitHub Wiki

Welcome to the error_Android_vaibhav wiki!

EACCES for API 34 android java.io.FileNotFoundException: open failed: EACCES (Permission denied)

add to the manifest and if the permission is not approved by the user then aprove by

    if(SDK_INT >= 30){
        if(!Environment.isExternalStorageManager()){
            Snackbar.make(findViewById(android.R.id.content), "Permission needed!", Snackbar.LENGTH_INDEFINITE)
                    .setAction("Settings", new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            try {
                                Uri uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID);
                                Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri);
                                startActivity(intent);
                            } catch (Exception ex){
                                Intent intent = new Intent();
                                intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
                                startActivity(intent);
                            }
                        }
                    })
                    .show();
        }
    }