Android Question Find path in different versions of "old" android

vecino

Well-Known Member
Licensed User
Longtime User
Hi, how can I find the paths to external usb, in android with API<23 ?
Regards.
 

DonManfred

Expert
Licensed User
Longtime User
You can try

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
            If storage.isExternalStorageRemovable(mnt&f) Then
                Log ("Device = "& f&":"&mnt&f&" is removable")
                If File.ListFiles(mnt&f).IsInitialized Then
                    Log("probably ExtSDCard: "&mnt&f)
                    extsdcard = mnt&f
                Else
                    'Log("Problem reading "&mnt&f)
                End If
            Else
                Log ("Device = "& f&":"&mnt&f&" is NOT removable")
            End If
        Next
    End If
    Log("extsdcard probably="&extsdcard)
    For Each f As String In File.ListFiles(extsdcard)
        Log(">"&f)
    Next

** Activity (main) Create, isFirst = true **
DIRECTORY_ALARMS=Alarms
DIRECTORY_DCIM=DCIM
DIRECTORY_DOCUMENTS=Documents
DIRECTORY_DOWNLOADS=Download
DIRECTORY_MOVIES=Movies
DIRECTORY_MUSIC=Music
DIRECTORY_NOTIFICATIONS=Notifications
DIRECTORY_PICTURES=Pictures
DIRECTORY_PODCASTS=Podcasts
DIRECTORY_RINGTONES=Ringtones
DirRootExternal = /storage/emulated/0
mount point = /storage/
Device = usbdisk:/storage/usbdisk is removable
Device = sdcard1:/storage/sdcard1 is removable
probably ExtSDCard: /storage/sdcard1
Device = sdcard0:/storage/sdcard0 is NOT removable
Device = emulated:/storage/emulated is NOT removable
extsdcard=/storage/sdcard1
>I am a FOLDER on the External SDCard
>I am a file on the External SDCard.txt
>LOST.DIR
>.android_secure
>Android
>DCIM
>carbon
>data
** Activity (main) Resume **
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, what is "storage"?
B4X:
If storage.isExternalStorageRemovable(mnt&f) Then
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks for your help.
Although most of my clients have android <5 and I can not use that library.
I have edited the code to go through what is in "mount" and with that I think it will help me.
Regards.
 
Upvote 0
Top