#Region  Project Attributes
    #ApplicationLabel: Sdcardcheck
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
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).
    Dim introot As String
    Dim testfolder, subfolder As String
    Dim intern As Boolean
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")
 
    File.MakeDir(File.DirRootExternal, "gd_extsd_test")
    testfolder = "Android/data"
    subfolder = "checkfolder"
    GetSDCardFolder
 
    File.Delete(File.DirRootExternal, "gd_extsd_test")
 
    Msgbox("SDCard intern: " & Chr(10) & introot & Chr(10) & Chr(10) & "SDCard extern: " & Chr(10) & extroot,"Info")
 
    ExitApplication
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GetSDCardFolder
    Dim eintrag As String
    Dim SDf As String
    Dim alldirs As List
    alldirs.Initialize
    Dim subdirs As List
    subdirs.Initialize
 
    alldirs.AddAll(File.ListFiles("/storage"))
    For i= 0 To alldirs.Size-1
        eintrag = alldirs.Get(i)
        If File.IsDirectory("/storage",eintrag) = True Then
            Try
                subdirs.AddAll(File.ListFiles("/storage/" & eintrag))
                If subdirs.IndexOf("gd_extsd_test")>-1 Then
                    intern=True
                Else
                    intern=False
                End If
             
                File.MakeDir("/storage/" & eintrag & "/" & testfolder & "/", subfolder)
                If File.IsDirectory("/storage/" & eintrag & "/" & testfolder & "/", subfolder) Then
                    SDf="/storage/" & eintrag & "/" & testfolder & "/" & subfolder
                    If WriteTest(SDf) Then
                        If intern Then
                            introot="/storage/" & eintrag
                            Log(" ")
                            Log("SDCard intern: " & introot)
                        Else
                            extroot="/storage/" & eintrag
                            Log(" ")
                            Log("SDCard extern: " & extroot)
                        End If
                        File.Delete("/storage/" & eintrag & "/" & testfolder, subfolder)
                        File.Delete("/storage/" & eintrag,testfolder)
                    End If
                End If
            Catch
                Log(LastException.Message)
            End Try
        End If
    Next
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