Here is an example to get SD Card space.
Place CheckSDCard in code module.
Please upload improvements
useage:
Log(codemodule.CheckSDCard("total"))
Log(codemodule.CheckSDCard("used"))
Log(codemodule.CheckSDCard("available"))
If codemodule.CheckSDCard("available") > 10000 Then
Log("Enough memory to install")
End If
' codemodule
Place CheckSDCard in code module.
Please upload improvements
useage:
Log(codemodule.CheckSDCard("total"))
Log(codemodule.CheckSDCard("used"))
Log(codemodule.CheckSDCard("available"))
If codemodule.CheckSDCard("available") > 10000 Then
Log("Enough memory to install")
End If
' codemodule
B4X:
Sub CheckSDCard(type_ As String)
Dim p As Phone
Dim sb As StringBuilder
Dim splitLine() As String
Dim splitLine1() As String
Dim s1 As String
' Initialize stringbuilder
sb.Initialize
' get memory info of sd card
p.Shell("df", Array As String("sdcard"), sb, Null) ' free space
'split memory info lines
splitLine=Regex.Split(",",sb.ToString)
If type_="total" Then
splitLine1=Regex.Split("K",splitLine(0))
s1=splitline1(0)
s1=s1.Replace("sdcard: ","")
splitline1(0)=s1
'Log(splitline1(0))
Else If type_="used" Then
splitLine1=Regex.Split("K",splitLine(1))
'Log(splitline1(0))
Else If type_="available" Then
splitLine1=Regex.Split("K",splitLine(2))
'Log(splitline1(0))
End If
Return splitline1(0).Trim
End Sub