Android Question Update Apk

edgar_ortiz

Active Member
Licensed User
Longtime User
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:

B4X:
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
 

udg

Expert
Licensed User
Longtime User
Hi Edgar,
I would do something like:
B4X:
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

MaFu

Well-Known Member
Licensed User
Longtime User
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
Top