Android Question DirRootExternal

lymey

Active Member
Licensed User
Longtime User
Hi!
I am writing an app that creates a directory off DirRootExternal. The problem is that on some devices this equates to mnt/sdcard and others mnt/local. In other words the external directory is on a removable card in the first case, and not in the second.

How can I determine if the actual location is the 'fixed' (mnt/local) directory, or the actual removable sdcard directory (mnt/sdcard) on a device that has both?
 

margret

Well-Known Member
Licensed User
Longtime User
You can try this code:
B4X:
Sub DevicePaths
     Dim lp, dPaths As List : Dim ChkVal, dp = File.DirRootExternal As String : dPaths.Initialize
     lp = File.ReadList("/system/etc/", "vold.fstab")
     For i = 0 To lp.Size -1
          ChkVal = lp.get(i) : ChkVal = ChkVal.Replace(":", " ")
          If ChkVal.ToLowerCase.StartsWith("dev_mount") Then
               dPaths.Add(SGW(ChkVal, 2) & ", " & SGW(ChkVal, 3))
          EndIf
     Next
     InputList(dPaths, "Device Mounting Paths", -1)
End Sub
Sub SGW(CStr As String, GE As Int) As String
     Dim t As List : Dim rs, sd As String : sd = " "
     t = Regex.Split(sd, CStr)
     rs = t.Get(GE-1)
     Return rs
End Sub
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
The way it's done and the permissions have changed, read THIS document.

I mentioned on my previous post that external storage is not standard because Android only supports the internal SDCard, access to the external is usually exposed by the manufacturer.
 
Upvote 0

lymey

Active Member
Licensed User
Longtime User
You can try this code:
B4X:
Sub DevicePaths
     Dim lp, dPaths As List : Dim ChkVal, dp = File.DirRootExternal As String : dPaths.Initialize
     lp = File.ReadList("/system/etc/", "vold.fstab")
     For i = 0 To lp.Size -1
          ChkVal = lp.get(i) : ChkVal = ChkVal.Replace(":", " ")
          If ChkVal.ToLowerCase.StartsWith("dev_mount") Then
               dPaths.Add(SGW(ChkVal, 2) & ", " & SGW(ChkVal, 3))
          EndIf
     Next
     InputList(dPaths, "Device Mounting Paths", -1)
End Sub
Sub SGW(CStr As String, GE As Int) As String
     Dim t As List : Dim rs, sd As String : sd = " "
     t = Regex.Split(sd, CStr)
     rs = t.Get(GE-1)
     Return rs
End Sub
Thanks margret I will give it a try!
 
Upvote 0

lymey

Active Member
Licensed User
Longtime User
DirRootExternal points to the INTERNAL SDCard, external SDCards are not really standard, there are several discussions about, it if you are curious, search the forums.
Thanks, I have been doing that without finding an answer for my problem unfortunately.
 
Upvote 0
Top