Android Question How should "/Download" folder be handled in API 30?

Andris

Active Member
Licensed User
Longtime User
In a previous thread I ended up solving a File.ListFiles problem under API 29 by adding
B4X:
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
to my manifest editor.

Erel's recommendation, as stated in https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/ , is
It will not work with targetSdkVersion=30. Avoid using File.DirRootExternal. Either use File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal.

So what's the best way to handle downloaded files that arrive in the /Download folder (via emails, Google Drive downloads, etc) in API 30, which at some point we'll be forced to use? API 30 will not recognize "requestLegacyExternalStorage." As I encountered in my previous thread, not having that manifest option will cause non-media files (like KML files) to be invisible in File.ListFiles. How then would we access those files so that we could move them to File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal?
 

agraham

Expert
Licensed User
Longtime User
If your apps don't need to go into the Play Store you can just keep targeting API 28 or 29. If you need to target API 30 for some reason and still don't need the Play Store then the forthcoming MANAGE_EXTERNAL_STORAGE permission will probably work and which is what I will try when the time comes. I'm staying at API 28 for the time being.
Google will only allow certain carefully curated apps in the Play Store to use this permission so you will probably need to implement some intents to open certain file types so that a permitted File Manager app can invoke your app to handle such files. I bow out and leave you to others at this point because I don't really know enough about Intents as I seldom use them and then only as boilerplate code.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
one way (and, perhaps soon, the only way) is to make your app a target for sharing. per this
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
my app accepts images shared by users who open the picture gallery and share a given image or set of images with my app (eg, for image manipulation). i don't need to know what's where. your app would would have to accept all types of files (note where that setting is made in the manifest) based on the description of the file types you're looking to store locally. otherwise your app does not appear as a target. open your downloads folder, select some file and then select the "share" icon. check out which apps appear as candidates for sharing the file. some day your app will appear in that list. once you've copied it over, you can store it locally. or pass it along to some app (that requires a different provider)
 
Upvote 0
Top