Let’s say that I have a SQLite database that I create in a separate program and include in the assets folder to be copied when the application starts (assuming it doesn’t already exist). The database contains two columns, A and B. Let’s say that A contains a list of locations (Paris, London, New York, etc– things the user cannot edit) and B stores the amount of times the user has visited the respective location (which the user CAN edit from within the app).
Now let’s say I managed to spell the name of a location wrong in my original database. I go into my SQLite browser, make a quick fix to that entry, save it, and replace the old DB file in my assets folder. How do I update column A in the database that has already been copied to reflect the changes I made to the now read-only database in the assets folder WITHOUT wiping the data they have stored?
My initial impression was to use onUpgrade, but I’ve seen people say it’s just for updating the schema of a database. In this case, my schema hasn’t changed, only some data within it…
onUpgradeis correct to use for what you need. I update both schema and static data during upgrades. My onUpgrade structured like so: