Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim p As Object
label1.Initialize("")
Log("file.DirInternal= " & File.DirInternal )
Log("File.DirDefaultExternal= " & File.DirDefaultExternal )
Log("File.DirRootExternal= " & File.DirRootExternal )
Log("File.ExternalWritable= " & File.ExternalWritable )
SDCards
Log( path_external_sdcard)
Dim Rslt As Boolean
Rslt= File.Exists(path_external_sdcard & "/Testfolder/","111.txt")
If Rslt=True Then
Log( "file 111.txt found on path " &path_external_sdcard)
label1.text=File.ReadString(path_external_sdcard&"/Testfolder","111.txt")
Log ("Text on file is= " &label1.text)
Else
Log ("file 111.txt not found on path " &path_external_sdcard )
End If
Dim paths() As Object = GetContext.RunMethod("getExternalFilesDirs", Array(Null))
For Each p As Object In paths
Log(p)
Next
Try
Dim folder As String = rp.GetAllSafeDirsExternal ("")
Log("folder= " & folder)
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Catch
Msgbox("no permission", "check permission ")
End Try
For Each s As String In rp.GetAllSafeDirsExternal("")
Log(s)
Next
File.WriteString(path_external_sdcard&"/Testfolder","111.txt", "00000")
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
Dim z As String
Dim R As String
If Permission = rp.PERMISSION_WRITE_EXTERNAL_STORAGE Then
If Result = True Then
'do whatever you need to do with the sd card
z=rp.GetAllSafeDirsExternal ("")
File.MakeDir(z, "mytxt1")
Dim Rslt As Boolean
Rslt= File.Exists(s & "/Testfolder/","111.txt")
If Rslt=True Then
label1.text=File.ReadString(s&"/Testfolder","111.txt")
Log ("Text on file is= " &label1.text)
Else
Log ("file 111.txt not found on path " &s )
End If
Else
End If
End If
End Sub
Sub SDCards
Dim Result As List
Result.Initialize
Dim tr As TextReader
tr.Initialize(File.OpenInput("/proc","mounts"))
Dim line As String
Do While True
line = tr.ReadLine
If line = Null Then Exit
' cols: dev mount type options ......
Dim Col() As String = Regex.Split(" ",line)
' things to ignore
' put your false positive mount points here
If Col(1).StartsWith("/dev") Then Continue
If Col(1).StartsWith("/proc") Then Continue
If Col(1).StartsWith("/sys") Then Continue
If Col(1).StartsWith("/system") Then Continue
If Col(1).StartsWith("/firmware") Then Continue
If Col(1).StartsWith("/data") Then Continue
If Col(1).StartsWith("/mnt/shell") Then Continue
' vfat is what we are interested in, but my nexus 5 also uses fuse
If Col(2) = "vfat" Or Col(2) = "fuse" Then
Dim s As String = Col(1)
Result.Add(s)
End If
Log (s)
Loop
tr.Close
Dim l As List '
l.Initialize
Log("")
Log("path on SDcards")
For i = 0 To Result.Size - 1
l.Add(Result.Get(i))
Log (l)
Next
Dim res As Int
path_external_sdcard=Result.Get(res)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub