Jump to content
Sign in to follow this  

How to deal with requestLegavyExternalStorage in Android 10/11?

Recommended Posts

I'm currently storing binary files generated by my app or uploaded to the device by the user (e.g. via Windows Explorer)

in the public downloads path returned by TPath.GetSharedDownloadsPath.


Using such a path which is not within the installed app itself is only possible in Android 10 when requestLegavyExternalStorage

is being declared in the AndroidManifest.template.xml. But that is a solution only viable when targeting Android 10, but not when
targeting Android 11, which will be a requirement somewhere in 2021.


Now I'm looking for possible alternatives which come as close to what I currently have as possible.

I have written a dialog listing all the files of my file type and when the user taps one he gets options to open it, display file meta data
in a popup or share it via share sheet.


I'm a bit lost about which route to go. I don't think MediaFramework would be the right approach as my file type is no media file.

I've seen this one:



        Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
            type = "*/*"
            putExtra(Intent.EXTRA_MIME_TYPES, arrayOf(
                    "application/pdf", // .pdf
                    "application/vnd.oasis.opendocument.text", // .odt
                    "text/plain" // .txt

But I'm not really sure what it does. Ok, it calls some activity to select a file, but since my file type is binary with some specific
suffix I'd like to list only files with that suffix and the other thing is: what do I get back?
How do I get at my file's contents?


And the other issue is, that the same dialog s used for saving files as well. They might be saved in some app package specific directory
if share sheet can work for that, but it still would be more cumbersome for users having the device directly connected via Windows Explorer.
They most likely couldn't get at the file anymore.


Any ideas?


Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this