Android Question Give File Write permission on SDcard (in a new directory)

Jim-WI

Member
Licensed User
I'd like to add file write permission for a file (and directory) on my SDcard. I'm on a phone with Android 10, B4A version 10.0.
It works for files in: "/storage/9016-4EF8/Android/data/b4a.example/files"
I got that directory using: GetAllSafeDirsExternal("")
I would like to be able to write file in another directory (that I created) on the SDcard.
Thanks,
Jim
 

DonManfred

Expert
Licensed User
Longtime User

To access SDCards you need to use the ExternalStorage Class.

 
Upvote 0

Jim-WI

Member
Licensed User
I'm still struggling with being able to write to a file on my sdcard that is not in the directory: "/storage/9016-4EF8/Android/data/b4a.example/files"
I got that directory using: GetAllSafeDirsExternal(""). I have updated to 10.2 B4A.
I did run the FilePicker app suggest to me. That app is here: https://www.b4x.com/android/forum/t...access-sd-cards-and-usb-sticks.90238/#content
The FilePicker app can access the sdcard files (by listing them), but the details of the code to access the files seems hidden in the ExternalStorage library. I can't figure out how to get the actual file name of the sdcard file so I can that file via:
TextReader1.Initialize(File.OpenInput(File.DirRootExternal, fname)) or
fileIn = File.OpenInput(dir, fnamein) {for binary files}.
Also I'd like to access an sdcard file without having to go thru FilePicker, hopefully using its filename.
If the files are in the main stotage area (not the sdcard - /storage/emulated/0/...) I can acces them (read / write). I can also read/write files in the special sdcard directory "/storage/9016-4EF8/Android/data/b4a.example/files". BUT, I can only access sdcard files that are in that special directory.
Still looking for advice / suggestions . . . Thanks
 
Upvote 0

Jim-WI

Member
Licensed User
Thanks, agraham. I was beginning to believe that was the case.
Using GetAllSafeDirsExternal, I get one folder that is on the sdcard. It is: "/storage/9016-4EF8/Android/data/b4a.example/files". Is there a way that I can add another folder on the sdcard so it is returned when I invoke GetAllSafeDirsExternal? I'd like that folder to have the same "rights and privilages" as the b4a.example/files folder.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…