I need the user to select a file of a custom filetype that they've dragged onto their android device from windows file explorer, but the internal storage option isn't available by default.
When I launch the intent using this:
var libraryIntent = new Intent(Intent.ActionOpenDocument);
libraryIntent.SetType("application/*");
_activity.StartActivityForResult(libraryIntent, (int)ActivityRequestCode.ImportFeatureCodeLibrary);
Android OS (5.1 and 6.0) shows the following screen:
The user has to know to go to the button in the top right and select the option to show internal file storage:
They have to click the hamburger again and only then does it show up in the list:
Is there a way to have this option show up in the list by default, or even better to have the user dropped into the "internal storage" file picker?
To enable scoped storage in your app, regardless of your app's target SDK version and manifest flag values, enable the following app compatibility flags: DEFAULT_SCOPED_STORAGE (enabled for all apps by default) FORCE_ENABLE_SCOPED_STORAGE (disabled for all apps by default)
So, you use ACTION_OPEN_DOCUMENT to request that the user choose a document. You take the Uri that you get and eventually you call openOutputStream() on a ContentResolver , passing in that Uri . You then try to write content out to that stream, to be able to store that content in the user-chosen document.
Scoped storage is the default behavior in Android 10 and 11. Once the app has been whitelisted on Google Play, the user can be asked for special permission. The Media Store in Android 11 has been upgraded. The user may bulk delete/edit media files, which was not possible in Android 10.
You can add an extra to the intent
:
libraryIntent.PutExtra("android.content.extra.SHOW_ADVANCED", true);
As far as I know it's an undocumented extra, but it seams to work from API 19 to at least 26
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With