In my Android application, I save several files in the Environment.getExternalStorageDirectory() + "\MyApp" directory. This worked great before updating Android 6 Marshmallow. After updating marshmallow, I cannot write to this directory.
As described in this answer, in marshmallows, applications need to ask the user for permission at runtime before writing to external storage.
But, when I use context.getExternalFilesDir(null) instead of Environment.getExternalStorageDirectory() , I don't need to request any permissions at runtime, and it just works (the path returned from context.getExternalFilesDir(null) is also in the external repository directory).
Is this some kind of coincidence, or can I continue to write to context.getExternalFilesDir(null) without asking permission at runtime?
source share