E edgar_ortiz Active Member Licensed User Longtime User Dec 12, 2016 #1 Hi, I have a Apk that I need to update... the new code is updated... my problem is that the data base is not "refreshed"... I use: Code: If File.Exists(gDirectorioDB,"database.db3") = False Then File.Copy(File.DirAssets,"database.db3",gDirectorioDB,"database.db3") End If How can I do to "delete" the current database and use the "NEW" database. Regards, Edgar
Hi, I have a Apk that I need to update... the new code is updated... my problem is that the data base is not "refreshed"... I use: Code: If File.Exists(gDirectorioDB,"database.db3") = False Then File.Copy(File.DirAssets,"database.db3",gDirectorioDB,"database.db3") End If How can I do to "delete" the current database and use the "NEW" database. Regards, Edgar
Erel B4X founder Staff member Licensed User Longtime User Dec 12, 2016 #2 Close the SQL object before you copy the file and then initialize it again. Upvote 0
udg Expert Licensed User Longtime User Dec 12, 2016 #3 Hi Edgar, I would do something like: Code: If File.Exists(gDirectorioDB,"database.old") Then 'delete(gDirectorioDB,"database.old") end if 'rename(gDirectorioDB,"database.db3","database.old") File.Copy(File.DirAssets,"database.db3",gDirectorioDB,"database.db3") Check the exact syntax for files commands above and apply the sequence at program start, when you are sure the SQL object is not yet initialized. In case something goes wrong with new DB you could revert back to its previous deploy. Upvote 0
Hi Edgar, I would do something like: Code: If File.Exists(gDirectorioDB,"database.old") Then 'delete(gDirectorioDB,"database.old") end if 'rename(gDirectorioDB,"database.db3","database.old") File.Copy(File.DirAssets,"database.db3",gDirectorioDB,"database.db3") Check the exact syntax for files commands above and apply the sequence at program start, when you are sure the SQL object is not yet initialized. In case something goes wrong with new DB you could revert back to its previous deploy.
MaFu Well-Known Member Licensed User Longtime User Dec 12, 2016 #4 You should add a configuration table in your database with a version field. Every time you take changes on the database increase the version number. Store the latest version number in the app. On app start check the version of the database and copy if it's not the newest version. Upvote 0
You should add a configuration table in your database with a version field. Every time you take changes on the database increase the version number. Store the latest version number in the app. On app start check the version of the database and copy if it's not the newest version.