title: Android 11 Write Access to sdcard/Android/someapp
body: <p>We are trying to migrate an app from 10 to 11 and this app modifies an XML file that is in another app's &quot;sdcard/Android/someapp&quot; dir. We have been browsing all over and there is a ton of stuff about this subject, none of which seem to give us write access this file any longer. This app works in 10 but not 11. We have requested the &quot;manage all files&quot; permission which seems to have been granted but still cannot read/write this any longer???
  Here is our code to request the permission ... are we missing something?</p>
  <pre><code>        if (getApplicationContext().getApplicationInfo().targetSdkVersion &gt;= Build.VERSION_CODES.R) {
  
              if (!Environment.isExternalStorageManager()){
                  try {
                      val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
                      intent.addCategory(&quot;android.intent.category.DEFAULT&quot;)
                      intent.data = Uri.parse(String.format(&quot;package:%s&quot;, applicationContext.packageName))
                      startActivityForResult(intent, 2296)
                  } catch (e: Exception) {
                      val intent = Intent()
                      intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
                      startActivityForResult(intent, 2296)
                  }
              }
          } else {
              //below android 11
              if (Environment.isExternalStorageLegacy()){
                  permissioncheck = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
                  if (permissioncheck == PackageManager.PERMISSION_DENIED){
                      ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_WRITE_EXTERNAL_CODE);
                  }
  
                  permissioncheck = ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE);
                  if (permissioncheck == PackageManager.PERMISSION_DENIED){
                      ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE), REQUEST_READ_EXTERNAL_CODE);
                  }
              }
          }
  </code></pre>
  <p>Thanks in advance!</p>