Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Private rp As RuntimePermissions
End Sub
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private FileHandler1 As FileHandler
    Private ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
    
    Activity.LoadLayout("Layout")
    FileHandler1.Initialize
    
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub Button1_Click
    Dim in As InputStream = File.OpenInput(File.DirAssets, "word1.txt")
    Wait For (FileHandler1.SaveAs(in, "text/plain", "word1.txt")) Complete (Success As Boolean)
    If Success Then
        ToastMessageShow("File saved successfully", True)
    Else
        ToastMessageShow("File not saved", True)
    End If
End Sub
Private Sub Button2_Click
    Dim bmp As Bitmap
    bmp.Initialize(File.DirAssets, "as.png")
    Dim fileName As String = "as.png"
    Dim dir As String = rp.GetSafeDirDefaultExternal("myFolder")
    Dim Out As OutputStream = File.OpenOutput(dir, fileName, False)
    bmp.WriteToStream(Out, 100, "JPEG")
    Out.Close
    ImageView1.Bitmap = bmp
End Sub