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?
 

elitevenkat

Active Member
Licensed User
Longtime User
It will not be automatic update!. You have to create a Sql script with alter / create command to accommodate the changes.
 
Upvote 0

TedDog

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

Dman

Active Member
Licensed User
Longtime User
Check and add a new table:

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