Android Question App upgrade with changed SQLite database

TedDog

Member
Licensed User
Longtime User
I plan on posting an update to my app that will include additional columns in my SQLite database, and possibly even a new table. What will happen to the existing database? Will it upgrade? Will data be lost?
 
It will not be automatic update!. You have to create a Sql script with alter / create command to accommodate the changes.
 
Upvote 0
It will not be automatic update!. You have to create a Sql script with alter / create command to accommodate the changes.

Would it be possible for you to give me an example? Also, what would be a good way to test if the database hadn't yet been updated, and the script needed to be run.
 
Upvote 0
Check and add a new table:

Code: Copy
If SQL1.ExecQuerySingleResult("SELECT count(name) FROM sqlite_master WHERE type='table' AND name='yourtablename'") = 0 Then
        SQL1.ExecNonQuery("CREATE TABLE yourtablename(field1 TEXT, field2 TEXT)")   
End If

Adding a column, I'd have to study and experiment on that one.

Hope it helps.
 
Upvote 0
Back
Top