'Returns external/physical SD Card directory
Public Sub getSDCardPath() As String
Dim iMount, iCRLF, iSlash, iAuto As Int
Dim fstab As String = File.ReadString("/system/etc/", "vold.fstab")
Dim Mount As String
Do While True
'get next line with mount point:
iMount = fstab.IndexOf2(CRLF & "dev_mount ", iCRLF) + 2
If iMount < 2 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 Return Mount
Loop
Return File.DirRootExternal
End Sub
Here is the vold.fstab file from my 7" Aluratek tablet 4.03...
Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
Jost aus Soest;
Now it should run correctly also on Margrets' Kindle Fire and Informatix' Nexus 7...
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))
End If
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
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
If dPaths.Size = 0 Then
dPaths.Add("/mnt/sdcard, /mnt/sdcard")
End If
File.OpenOutput(SGW(ChkVal, 3), "test.txt", False)
Or
File.OpenOutput("mnt/sdcard/ext_sd", "test.txt", False)
Not so fast. The issue still exists even with Joast latest code, at least in my case. It returned /mnt/sdcard when it should have been /mnt/extsd.
Are you sure, that you have used the unmodified latest version of my getSDCardPath-sub?
iMount = fstab.IndexOf2(CRLF & "dev_mount ", iCRLF) + 2
Read NJDude's post above. It is pretty conclusive.I however, tested it on another 7" tablet. It showed the correct SD path, but when I tried to copy a file to it, permission was denied.
@my friend TDS: The Aluratek 7" has ICS 4.03 and I can write to it and save files programmatically at will, but the other 7" has also ICS, but I cannot write to it.Read NJDude's post above. It is pretty conclusive.
Okay, this is a little confusing with you refering to 'other' 7 inch tab.@my friend TDS: The Aluratek 7" has ICS 4.03 and I can write to it and save files programmatically at will, but the other 7" has also ICS, but I cannot write to it.
MAHARES ANSWERS:It is an off brand called Newsmy with OS 4.03What is the manufacturer, model number of this?
MAHARES ANSWERS: I cannot write to the card via the below command. The error returned is "filenotfound Access DENIED". But I can copy any files I want to the card proper via file manager.:Can you not write to it via B4A apps, or you cannot write with any apps, so it is always read-only? Also log the exact error.
File.Copy(DBFilePath,TextFile,"/mnt/external_sd",TextFile)
MAHARES ANSWERS:Here it is attached:Post the vold.fstab of the other 7" tab.
'Returns external/physical SD Card directory
Public Sub getSDCardPath() As String
Dim LF As String = Chr(10) 'line feed' character
Dim CR As String = Chr(13) 'carriage return' character
Dim iMount, iLF, iSlash, iAuto As Int
Dim fstab As String = File.ReadString("/system/etc/", "vold.fstab")
Dim Mount As String
fstab = fstab.Replace(TAB, " ") 'replace tab characters
fstab = fstab.Replace(CR, LF) 'normalize linefeeds
fstab = fstab.Replace(":", " ") 'replace colon characters (Motorola-case)
Do While True
'get next line with mount point:
iMount = fstab.IndexOf2(LF & "dev_mount ", iLF) + 1
If iMount < 1 Then Exit
iLF = fstab.IndexOf2(LF, iMount)
If iLF < 0 Then Exit
Mount = fstab.SubString2(iMount, iLF)
'get mount path:
iSlash = Mount.IndexOf("/")
If iSlash < 0 Then Continue
iAuto = Mount.IndexOf2("auto", iSlash)
If iAuto < 0 Then Continue
Mount = Mount.SubString2(iSlash, iAuto).Trim
'return this one, if new:
If Mount <> File.DirRootExternal Then Return Mount
Loop
Return File.DirRootExternal
End Sub
@Jost: You are getting and inching closer, but for instance the Razr phone returns: /mnt/sdcard-ext:none:lun1 as a path using your latest version of getSDCardPath, which will of course crash unless I parse the string and get rid of the text from the colon on.I was able to adjust my sub, so it should run under "all circumstances
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?