I try to make a backup of an existing database. I use the example /Database/SQLite/SQLiteBackup.xojo_binary_project and it works.
My problem is, I do not want to ask the user for the destination folder and filename, I want to use the existing folder, rename the filename to mydatabase.sql_
What happens: my existing database file is renamed after this line
backupFile.Name = backupFile.Name + "_" + backupDate
and no backup file is created. Don’t understand why, because I do a copy/clone with the ‘New’ at line 1.
Full code:
[code] Dim backupFile As Folderitem = New FolderItem(pDatabase.DatabaseFile)
Dim now As Date = New Date
Dim backupDate As String = str(now.Year) + “.” + Format(now.Month,“00”) +"." + Format(now.Day,“00”) + “_” + Format(now.Hour,“00”) + Format(now.Minute,“00”) + Format(now.Second,“00”) 'creates a string like 2014.05.27_1920
backupFile.Name = backupFile.Name + “_” + backupDate
'backupFile = GetSaveFolderItem("", “backup.sqlite”) <- works
If backupFile Is Nil Then Return false
mBackupDB = New SQLiteDatabase
mBackupDB.DatabaseFile = backupFile
If mBackupDB.CreateDatabaseFile Then
mBackupHandler = New BackupHandler
'mBackupHandler.BackupProgressBar = BackupProgress
pDatabase.BackUp(mBackupDB, mBackupHandler)
End If[/code]