B4A Class Manage External Storage - access internal external storage >= SDK 30

Google seems intent on dumbing down Android to the point of uselessnes to me. I think of my devices as little computers and I want a proper file system on them, not the limited tortuous things that Google offers and that I don't understand, ContentChooser, FileProvider, ... o_O I'm getting old and can't cope with complications like that! :(

So here is a class that lets apps on SDK 30 and higher devices treat the file store as a real file store and not some dumbed down abstracted thing. ?

It uses a new permission that Google will not allow for most Play Store apps.
Manage all files on a storage device | Android Developers
As I will never have apps in the Play Store this worries me not one jot :p


The class uses code stolen from Erel's ExternalStorage class to provide a similar API - thank you Erel ?
ExternalStorage - Access SD cards and USB sticks | B4X Programming Forum

EDIT: Note the minor convenience code modification to Sub GetPermission in the ManageExternalStorage class suggested in post #3 below.
in.Initialize("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION", "package:" & Application.PackageName)

EDIT: If for some reason you need to access folders under Android/data or Android/obb there is a loophole in post #35 here. Note that this is probably not intentional on Googles part and may be may closed in the future. If your File Explorer on your device can access these folders this is how it is doing it.
FURTHER EDIT: This loophole now seems to be closed in Android14
 

Attachments

  • ManageExternalStorage_1.00.zip
    13.4 KB · Views: 3,333
Last edited:
Все, что работает с активностями, может работать и с B4XPages. Я не знаком с кодом, предполагаю, что вам нужно изменить Wait For Activity_PermissionResult на Wait For B4XPage_PermissionResult и он будет работать.
Thanks, I fixed it. But the program closes when requested to access files, without error logs!
 
There is always a stack trace + error message in the logs when the app crashes. Sometimes it is in the unfiltered logs.
Sorry. When there's a lot of code, you stop seeing the obvious! It is necessary to register the name of your package in the MES class! It's decided! Thank you.
 
Top