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

agraham

Expert
Licensed User
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
 

Attachments

Last edited:

Xfood

Well-Known Member
Licensed User
Small change to read the package name
Thank you @agraham
Thank you @Erel

B4X:
Public Sub GetPermission
    If HasPermission Then
        RaiseEvent
        Return
    End If
    Dim in As Intent
    ' Be sure to reference your app package name in "pakageg:xxx"                                             ^^^^^^^^^^^^^^^^^
    in.Initialize("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION", "package:" & Application.PackageName)
    StartActivityForResult(in)
End Sub
 
Top