We are trying to migrate an app from 10 to 11 and this app modifies an XML file that is in another app's "sdcard/Android/someapp" 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 "manage all files" 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?
if (getApplicationContext().getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()){
try {
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse(String.format("package:%s", 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);
}
}
}
Thanks in advance!
Looks like the bottom line is that you will NOT be able to WRITE to another apps external storage folder (/sdcard/Android/data/com.app.someapp) in And11+
Thanks for the help!