Select a non-own (non)media file from anywhere on Android 11+ and get full access without SAF or MANAGE_EXTERNAL_STORAGE

My extension is ONLY for Android 11+ (i.e., Scoped Storage). On Android < 11, neither SAF nor anything else is needed.

I have four devices running Android 11, 12, 13, and 16. Everything works perfectly on them. Three Google Pixel devices and one OnePlus 8 (Android 12). On all devices, I pick all files from the root directory of the external storage. Companion & APK.

If anyone has an Android 11+ device on which it doesn't work, please let me/us know the Android version and device name.

Also works for Android 13 in companion, and compiled if you request permission for filetype...

Hmm, my app (extension) doesn't need any permission at all.

I have tried this solution and it works on all versions of Android...

his app was compiled online. Using the offline compiler may produce unreliable results.
copy_to_ASD.aia (8.4 KB)

Interesting that the File component can read the text via a contentUri. But how do we get direct access to any file not owned by the app, not just text files, but all possible file types like PDF, JPG, PNG, MP4, MOV, etc.)?

Because that's what my topic is about.

Sorry for my English. I'm testing it with excellent results. Without opening the file, I use the copyfile from sharing with ResultUri. However, you need to specify the dataType, such as application/PDF or image/*. This way, the copy will occur without corrupting the files. I'll publish the blocks as soon as possible. P.S. Use an advanced explorer and not the default one to obtain correct resultUri, such as cxFileExplorer.

:question:

All formats work without corruption. If you don't use an advanced explorer, the resulting file name won't be the original one, but you can edit it and it will still work.



copy_file_to_ASD.aia (8.6 KB)

Yes, strange that this works with FileScope=Shared on Android 11+. I've noticed that before, too. Try copying to one of the Shared folders this way (e.g., /Download). In any case, on Android < 11 it doesn't work like this (i.e. via a contentUri).

It doesn't work with any other FileScope, especially not with Legacy.
Why? @ewpatton

You will notice that storage permissions are requested (of course, incorrectly).

True, it accepts SHARED as the starting point, but the file can be copied from any folder you select. So that's fine by me.

Without storage permissions? I don't think so.
(Tested on Android 16 with the APK.)

Tested android 15 ok.

Tested also on Android 13. Same result, you must grant storage permissions. Please test with the APK.

The first time you copy a file, it asks for permissions; the next time, it doesn't.
When you copy a file (.jpg, .mp3, ) whose filename contains spaces, they are filled with %20. To avoid this, I've inserted a replacement with _ in this block.

Yes, and that's generally the case that a granted permission will not be requested again.

However, of course, no permissions should be requested at all on Android 11+, especially not READ_MEDIA_IMAGES, which

  1. makes no sense at all for non-media files,
  2. has not been permitted by Google since May 2025, and
  3. is fundamentally unnecessary.

It should also be noted that all three READ_MEDIA_... permissions are requested and must be granted on Android 13+, which makes it even more absurd.

I've enhanced the extension a bit so that after selecting any file, it is copied to /Documents and from there moved to /Download/myFolder/. After restarting the app, you then have direct access to the source file (in my case, they are always picked from the root directory of the external storage) and can copy this file again to the destination folder without having to pick the file again.

This can be necessary, for example, if the source file was later modified by the user and you want/need to have full access to this updated file again. In my test app, text files or images are then displayed immediately. No permissions at all are required.

Blocks

Here's another approach, using the FilePicker, which is simpler and works on all Android versions. You can pick any file, copy it to /Documents, and then have full access to it. On Android 11+, no permissions are required (requested). For text files, images, and PDF files, the content is displayed immediately. Otherwise, the extension (mp4, mp3, ...) is displayed.

Blocks

In this way, permissions can be completely avoided, especially those that have been banned on Android 13+ since May 2025, such as READ_MEDIA_IMAGES and READ_MEDIA_VIDEO.

2 Likes