Get Removable sdcard Path

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have a very simple question but so far I am unable to find an answer of this question. "Is there any way of finding the absolute path of EXTERNAL (Removable Storage Card in Samsung Galaxy Tab 7.7)STORAGE DIRECTORY(SDCARD) in Android?"

Please don't recommend using File.DirRootExternal since it usually returns the path for internal storage (/mnt/sdcard).But My External sdcard that comes under /mnt/sdcard.Pls see the below

/mnt/sdcard --------->Device sdcard
/mnt/sdcard/extstorages/sdcard --------> External sdcard

Pls advise how to get absolute path of removable (/mnt/sdcard/extstorages/sdcard) .
 
Last edited:

jimcashby3

Member
Licensed User
Longtime User
What is the fix?

There has got to be a way for my application to send and receive files directly form an external removable SD Flash card on the Galaxy Tab
I have found hundreds of post on this issue.
Please, link all of them together with a concise answer!
Stop the madness!
 
Upvote 0

NevF

New Member
Licensed User
Longtime User
As I wrote above there is no API in Android to get the path of the SD card. In fact starting from Android 4.4 you can only read and write from a very specific folder in the sd card.

I have the same problem with SDCard Document folder not recognised using:
i.Initialize2("file://" & File.DirDefaultExternal & "/storage/sdcard1/PDF/Issue 1.pdf", 0)
I found the path above using the downloaded Root Browser from this site. Please, which 'very specific' folders on a sdcard mentioned above can be written to? 77 year old would-be B4A programmer. I have a Sony Experia Z Tablet with a 64gb sdcard.
 
Last edited:
Upvote 0

James Chamblin

Active Member
Licensed User
Longtime User
This seems to work. It works on my Galaxy S3 and a couple of virtual devices I tried it on. It will list all devices, including USB ones, so you need to figure out how to filter it to just the SD card.
B4X:
    Dim de As String = File.DirRootExternal
    Log ("DirRootExternal = "&de)
    Dim mtc As Matcher = Regex.Matcher("(/|\\)[^(/|\\)]*(/|\\)",de)
    If mtc.Find = True Then
        Dim mnt As String = mtc.Group(0)
        Log ("mount point = "& mnt)
        Dim dirs As List = File.ListFiles(mnt)
        For Each f As String In dirs
            Log ("Device = "& f)
        Next
    End If
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Works for me too
I´ve added code to get the path to MY external sdcard.

This code works on my device (Galaxy Note 3. Android 4.4.2)

B4X:
    Dim de As String = File.DirRootExternal
    Log ("DirRootExternal = "&de)
    Dim mtc As Matcher = Regex.Matcher("(/|\\)[^(/|\\)]*(/|\\)",de)
    Dim extsdcard As String = de
    If mtc.Find = True Then
        Dim mnt As String = mtc.Group(0)
       
        Log ("mount point = "& mnt)
        Dim dirs As List = File.ListFiles(mnt)
        For Each f As String In dirs
        Log ("Device = "& f)
            If f.ToLowerCase.Contains("extsdcard") Then
                extsdcard = mnt&f
            End If
        Next
    End If
    Log("extsdcard="&extsdcard)
    For Each f As String In File.ListFiles(extsdcard)
        Log(">"&f)
    Next

LogCat connected to: 9f1dbeed
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
** Activity (main) Create, isFirst = true **
DirRootExternal = /storage/emulated/0
mount point = /storage/
Device = container
Device = UsbDriveF
Device = UsbDriveE
Device = UsbDriveD
Device = UsbDriveC
Device = UsbDriveB
Device = UsbDriveA
Device = sdcard0
Device = extSdCard
Device = emulated
extsdcard=/storage/extSdCard
>LOST.DIR
>.android_secure
>Android
>DCIM
** Activity (main) Resume **

extsdcard001.png
 
Upvote 0
Top