Android QuestionIs there a way to update sqlite table on mobile without losing the data? What happen here is the sqlite on mobile will be overwritten from the PC.
File.Copy(File.DirAssets,"db.sql",File.DirInternal,"db.sql")
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirInternal, "db.sql", False)
End If
Only copy this file if it does not exists.
- If the DB has changed you need to do the changes in the local DB too instead of just fully overwrite it. New Tables, new Columns.
this is a problem when the structure of the DB has changed: you have to update the DB but want to keep the data
I'm also working on that but moved it to lower priority - from my company I know the ERP-system does it in this way:
1. create a second DB (eg "UpdateDB" with table "Updates") where you store all DBCC changes made to initial release
2. installing update: read and execute all DBCC changes from UpdateDB which are not included in the existing DB
3. copy these statements to the existing DB (new table "Updates") so that you can see that they were already executed by next update
Attention:
- you may (!) also have to init new tables, columns etc. to fit for the expected usage
- the DBCC changes may have to executed in correct order (eg. 1. add column, 2. init column); so the Update-table may look something like this to be sortable
col1: Version
col2: UpdateNr
col3: SQLstatement