Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim ExtRoot As String 'The obtained root directory for the actual physical external SD card (user supplied).
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
' Remove the Log lines.
ExtRoot=GetSDCardFolder
Log(" ")
Log(" ")
Log("GetSDCardFolder says: Ext Root directory = " & ExtRoot)
Log(" ")
ToastMessageShow( "GetSDCardFolder says: Ext Root directory = " & ExtRoot,True)
Activity.Finish
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GetSDCardFolder() As String
'*************************************************************
'Try to find the location of removable external sdcard memory,
'perform a write test and return the folder name, if writable.
'*************************************************************
Dim root As String=""
Dim folder As String=""
Dim SDf As String=""
'... 3
root = "/mnt"
folder = "sdcard3"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'---------------------------------------
' ... 2
'---------------------------------------
root = "/mnt"
folder = "sdcard2"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'----------------------------------------
'Quechua 5
'----------------------------------------
root = "/mnt"
folder = "sdcard1"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'----------------------------------------
'... 0
'----------------------------------------
root = "/mnt"
folder = "sdcard0"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'----------------------------------------
'porsi nada
'----------------------------------------
root = "/mnt"
folder = "sdcard"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'----------------------------------------
'"/mnt/extSdCard"
'----------------------------------------
root = "/mnt"
folder = "extSdCard"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------------
root="/storage"
folder="/extSdCard"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------------
root="/storage"
folder="/sdcard"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'------------------------------------
' Acer A500 Tablet
'------------------------------------
root = "/mnt"
folder = "external_sd"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'------------------------------------
'Samsung Galaxy S2
'-------------------------------------
root = File.DirRootExternal
folder = "external_sd"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
' ASUS TF 101 (Micro SD)
'-------------------------------------
root = "/mnt/sdcard/Removable"
folder = "MicroSD"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'------------------------------------
'Asus TF 101 (SD-Card Keyboard Dock)
'------------------------------------
root = "/mnt/sdcard/Removable"
folder = "SD"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "SD3"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "SD2"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "SD1"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "SD0"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'------------------------------------
root = "/mnt/sdcard/Removable"
folder = "sd"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "sd3"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "sd2"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "sd1"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
root = File.DirRootExternal
folder = "sd0"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
'HTC Desire
'-------------------------------------
root = File.DirRootExternal
folder = "sd"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'-------------------------------------
'MOTOROLA DROID 3
'-------------------------------------
root = "/mnt"
folder = "sdcard-ext"
SDf=TryExternalSD(root,folder)
If SDf<>"" Then Return SDf
'to be continued....
'return something real
Return File.DirRootExternal
End Sub
Sub TryExternalSD(Root As String, Folder As String) As String
Dim Result As String=""
Dim SDf As String =""
If File.IsDirectory(Root,Folder) Then
SDf=Root & "/" & Folder
If WriteTest(SDf) Then
Return SDf
Else
Return ""
End If
End If
End Sub
Sub WriteTest(dirname As String) As Boolean
Dim s As String
Try
File.WriteString(dirname,"test.tmp","test")
s=File.ReadString(dirname,"test.tmp")
File.Delete(dirname,"test.tmp")
Catch
Log(LastException.Message)
Return False
End Try
If s="test" Then
Return True
Else
Return False
End If
End Sub