Hi all,
I'm running into a strange problem with the SQLite database in my app. This only occurs on SDKversion 28 and higher.
My app uses a SQLite database to store astronomical observations. The app has a backup function so that the user can export a backup of the database to external storage for safe keeping or migration to another device. Before I backup the database, I close it and then I copy the database from Internal storage to the external storage. This is the code:
These actions run fine, I find the backup file in the external storage location.
But.
The backup file does not contain the changes written to the database since the application started!
So the app shows data that is not found in the backup database... The changes only show up in the backup after the app is closed, restarted and a new backup is made.
It looks like the runtime database is not stored in File.DirInternal until the app is closed.
Where do I find the runtime database?
I'm running into a strange problem with the SQLite database in my app. This only occurs on SDKversion 28 and higher.
My app uses a SQLite database to store astronomical observations. The app has a backup function so that the user can export a backup of the database to external storage for safe keeping or migration to another device. Before I backup the database, I close it and then I copy the database from Internal storage to the external storage. This is the code:
B4X:
Sub makeBackup
Dim strFileName As String
DateTime.DateFormat = "yyyy-MM-dd_HH-mm"
strFileName = "StarLog backup-" & DateTime.Date(DateTime.Now) & ".slbak"
Database.Close
Try
File.Copy(File.DirInternal, "StarLog.db", File.DirRootExternal & "/StarLog", strFileName)
JVCUtils.toastMessage(Activity,NVPanel,Main.trans.GetText("txtBackupSucces"))
Catch
JVCUtils.toastMessage(Activity,NVPanel,Main.trans.GetText("txtErrorMakingBackup"))
End Try
Database.Initialize(File.DirInternal, "StarLog.db", False)
End Sub
But.
The backup file does not contain the changes written to the database since the application started!
So the app shows data that is not found in the backup database... The changes only show up in the backup after the app is closed, restarted and a new backup is made.
It looks like the runtime database is not stored in File.DirInternal until the app is closed.
Where do I find the runtime database?