Android Question B4A - read from and write to the SD Card

js486dog

Active Member
Licensed User
Longtime User
Please,
how to read any source (text,image,osmdroid map) from SD Card and write to the SD Card ?
SD Card = a little memory item you insert to the Android device.
 

js486dog

Active Member
Licensed User
Longtime User
Note that there is no need to add B4A to the thread title as this is the B4A forum.

There is a single folder which you can access on Android 4.4+ devices. You can find it with RuntimePermissions.GetAllSafeDirsExternal.
Thank you very much Erel.
I will try it.

Jan
 
Upvote 0

epsharp

Member
Licensed User
Longtime User
js486dog defined SD Card as a little memory item that you insert!

Micro SD, Nano SD, whatever; it is NOT part of the device that you buy, it is an external memory card that you insert in order to have additional storage.

I have a Samsung Tab A (Android 5.1), Fusion5 (6.0) and Galaxy S8+ (7.0). All three have additional storage cards inserted. All three return a different folder with RuntimePermissions.GetAllSafeDirsExternal, but none of them are the additional storage card.

All three ultimately wind up at /Android/data/"packagename"/files, where I created a simple text file. Using an Android File Manager, when I look at the SD Card (external) under /Android/data, the folder is there, but not the file. When I look at Internal Storage under /Android/data, the folder also exists and the file is there also. I can delete the folder in both places, run my test program again and the same two folders are created but the file is ONLY in internal storage.

Ed Sharp

UPDATE:

In runtimepermissions documentation:

GetAllSafeDirsExternal (SubFolder As String) As String()
... On older versions only one folder will be returned.

I never checked but just used list.get(0). In fact, this permission returns two (2) folders. The first one is internal memory, the SECOND one points to the External SD Card. Test program puts the test file on the SD card now.

My apologies.
 
Last edited:
Upvote 0

js486dog

Active Member
Licensed User
Longtime User
Note that there is no need to add B4A to the thread title as this is the B4A forum.

There is a single folder which you can access on Android 4.4+ devices. You can find it with RuntimePermissions.GetAllSafeDirsExternal.
Thanks Erel,

CODE(
Dim rp As RuntimePermissions
Log("Internal: " & File.DirInternal)
For Each s As String In rp.GetAllSafeDirsExternal("")
Log(s)
Next
)

works fine for me on Asus Zenfone 2 Laser. MicroSD is:

/storage/E026-55B3/Android/data/myapp/files

Little long string to search in MicroSD. I will try to cut off :
/Android/data/myapp/files
to write directly to:
/storage/E026-55B3/myapp .

Jan
 
Upvote 0
Top