I am testing my app on a device that runs Android 9. The app now targets Android 11 as per my Gradle file:
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.xxx.yyy.zzz"
minSdkVersion 15
targetSdkVersion 30
versionCode 15455
versionName "4.55"
multiDexEnabled true
}
Before running the app, I deleted the previous version from the test device.
When the app targeting Android 11 is run with the following code:
try {
File oldDir = new File(Environment.getExternalStorageDirectory(), "MyFolder");
File afile = new File(oldDir, "myFile.boo");
afile.createNewFile();
}
catch(IOException e){}
The app creates MyFolder/myFile.boo which is accessible and deletable.
The developer docs clearly state: https://developer.android.com/about/versions/11/privacy
"Apps that target Android 11 or higher are always subject to scoped storage behaviors." The docs do not mention any exceptions for a particular phone's android build.
Why am I able to create and access this file under the new scoped storage restrictions when my app has declared that it will be using scoped storage?