Private Storage As ExternalStorage
Private UpItem As ExternalFile
...
Storage.Initialize (Me, "Storage")
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
...
Sub CopyMapToDownloadAndOpen(Folders() As String, Filename As String)
Dim extfolder As ExternalFile
Dim extfile As ExternalFile
Storage.SelectDir(True)
Wait For Storage_ExternalFolderAvailable
Dim extfolder As ExternalFile = Storage.FindFile(Storage.Root, Folders(0))
Log("Folder " & Folders(0) & " found: " & extfolder.IsInitialized)
If Folders.Length > 1 Then
For i = 1 To Folders.Length -1
extfolder = Storage.FindFile(extfolder, Folders(i))
Log("Folder " & Folders(i) & " found: " & extfolder.IsInitialized)
Next
End If
If extfolder.IsInitialized Then
Dim extfile As ExternalFile = Storage.FindFile(extfolder, Filename)
Log("File " & Filename & " found: " & extfolder.IsInitialized)
If extfile.IsInitialized Then
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "/DownLoad/OS Search Map.jpg", False)
File.Copy2(Storage.OpenInputStream(extfile), out)
out.Close
End If
End If
Starter.ViewerFilename = Starter.MapTempFilename
StartActivity(Viewer)
End Sub
' Copy "/Maps OS District Jpg/SJ/SJ46.jpg" to temporary file
Sub btnDistrict_Click
Starter.ViewerZoom = Starter.MapDistrictZoom
CopyMapToDownloadAndOPen(Array As String("Maps OS District Jpg", "SJ"), "SJ46.jpg")
End Sub