Hi everybody,
I have written this:
Thanks jost-aus-soest for the base of this sub. It returns the path to APP's directory on the first SD mounted or internal memory if SD is not present. It doesn't check if APP's directory is created. If there are two external memories mounted its behaviour is not predictable...
I'd like if somebody could check the code under different devices...
Ciao
Mauro
I have written this:
B4X:
Public Sub getSDCardPath() As String
' Private rp As RuntimePermissions
Dim iMount, iCRLF, iSlash, iAuto As Int
Dim fstab As String = File.ReadString("/system/etc/", "vold.fstab")
Dim Mount As String
Dim exten As String=File.DirDefaultExternal
Dim ptr1 As Int=exten.IndexOf("Android")
If ptr1=0 Then
Msgbox ("Unknown directory:" & exten,"Error")
End If
Do While True
'get next line with mount point:
iMount = fstab.IndexOf2("dev_mount ", iCRLF)
If iMount < 0 Then Exit
iCRLF = fstab.IndexOf2(CRLF, iMount)
If iCRLF < 0 Then Exit
Mount = fstab.SubString2(iMount, iCRLF)
'get mount path:
iSlash = Mount.IndexOf("/")
If iSlash < 0 Then Continue
iAuto = Mount.IndexOf2("auto", iSlash)
If iAuto < iSlash Then Continue
Mount = Mount.SubString2(iSlash, iAuto).Trim
'return this one, if new:
If Mount <> File.DirRootExternal Then
Try
Dim files As List=File.ListFiles(Mount)
If files.IsInitialized Then
Return Mount & "/" & exten.SubString(ptr1)
End If
Catch
End Try
End If
Loop
Return File.DirDefaultExternal
End Sub
Thanks jost-aus-soest for the base of this sub. It returns the path to APP's directory on the first SD mounted or internal memory if SD is not present. It doesn't check if APP's directory is created. If there are two external memories mounted its behaviour is not predictable...
I'd like if somebody could check the code under different devices...
Ciao
Mauro