I have a dilemma regarding a free app that I allow users to import their data (an sqlite file on the SD card) to a paid app.
After doing these updates; I realized that if I need to make future changes to the database, the user will need to import the same DB version (from the free app) to the existing version (of the paid app).
Real life example:
Let's say version 1 of both apps has 1 table with 5 columns. I do an upgrade to v2, now the 1 table has 6 columns.
When a potential user does an import within the paid app to bring in data from the free app, there is a chance that the free app can be on DB version 1 (if user didn't update app recently) while the paid app would be looking for DB version 2. This I assume leads to a crash on startup.
How can I do a check like this in the paid app before doing import: (pseudo code)
File olddb = oldDb.db; // get the back up file here from SD
int piadAppDBVersion = 2; // check for the current version of the database in paid app
if (olddb.getDatabaseVersion() == getPaidAppDBVersion()) { // made up functions
// allow import;
} else {
// Toast "Your databases are incompatible"
}
So the two questions: 1. If the above code is an appropriate solution to ensure compatibility, how can this be done? 2. If the above is not a standard solution to my problem, then what is?
Side note: My import consists of a simple file copy: copying a backcup db on external storage and overwriting the db on internal storage.