I have an SQLite database in the first version of my Windows app (which is on the Windows store). Now I want to release the second version of the application, which also has an SQLite database in it with new tables added.
I have my data saved in first version and don't want to lose them.
I found that Android has onCreate
and onUpgrade
methods for handling sqlite database versions. Android: upgrading DB version and adding new table .
Similar question is here. But that is for iOS.
Is there any similar solutions for Windows Runtime Apps(Windows 8.1 and Windows Phone 8.1)? Please suggest some alternatives.
Thanks in advance.
A better (for performance) way to have a version of the DB is to use the "PRAGMA user_version"
var sqLiteAsyncConnection = new SQLiteAsyncConnection(path);
// read the user version
var version = sqLiteAsyncConnection.ExecuteScalar<string>("PRAGMA user_version");
perfMon.TraceSinceLast("StandardQueryBase : db version read");
if (version == "0")
{
// update the schema here
// store the new version number in the DB
sqLiteAsyncConnection.ExecuteScalar<string>("PRAGMA user_version=1;");
}