SQLiteBackupInterface

From Xojo Documentation

Interface


Used to get progress and status of SQLiteDatabase backups.

Methods
Complete Progress
Error

Notes

This interface is used when you want to track the progress of an asynchronous backup of a SQLiteDatabase using SQLiteDatabase.Backup.

You create a class that implements this interface and then add code to the methods. The methods are called as the backup progresses.

The class must remain in scope while the backup is running.

Sample Code

Backing up the database asynchronously requires the use of a separate class that implements SQLiteBackupInterface.

Var backupFile As Folderitem
backupFile = FolderItem.ShowSaveFileDialog("", "backup.sqlite")

If backupFile Is Nil Then Return

// This is a property on the Window so that it stays in scope when the method exits
mBackupDB = New SQLiteDatabase
mBackupDB.DatabaseFile = backupFile
If mBackupDB.CreateDatabaseFile Then
// This is a property on the Window so that it stays in scope when the method exits
mBackupHandler = New BackupHandler

// The window has a progress bar that is updated as the backup progresses
mBackupHandler.BackupProgressBar = BackupProgress
mDB.BackUp(mBackupDB, mBackupHandler)
End If

A class called BackupHandler implements SQLiteBackupInterface and has code in these methods:

Complete:

MessageBox("Backup Complete.")

Error:

MessageBox("There was an error during the backup: " + Str(errorCode))

Progress:

If BackupProgressBar <> Nil Then
BackupProgressBar.Maximum = 100
BackupProgressBar.Visible = True
BackupProgressBar.Value = percent*100
End If

In addition, it has a public property for the progress bar:

BackupProgressBar As ProgressBar

Example Project

/Example Projects/Database/SQLite/SQLiteBackup

See Also

SQLiteDatabase.Backup