Sub Globals
Dim permitted as Boolean
End Sub
. . .
. . .
' Prepare to backup file
Sub makeBackup
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Do While Not(permitted)
Sleep(10)
Loop
backup(filename) ' Only runs if permission is given
End Sub
' Handle permission request result
Sub Activity_PermissionResult(Permission As String, Result As Boolean)
permitted = Result
If (permitted = False) Then ExitApplication ' Assumes that permission is essential
End Sub
' Backup file to external storage - folder name is "backup"
Private Sub Backup(filename As String)
' If a previous backup exists then remove it
If File.Exists(File.DirRootExternal & "/backup", filename) Then
File.Delete(File.DirRootExternal & "/backup", filename)
Else
' If a previous backup does not exist then create a backup folder
File.MakeDir(File.DirRootExternal, "/backup")
End If
' Copy the current internal file to the external backup
File.Copy(File.DirInternal, filename, File.DirRootExternal & "/backup", filename)
End Sub