Windows store app how to update sqlite database structure


  • Hi,

    I have developed an windows store app and It is stored in the market.

    The app use a local SQLite database.

    My question is this:

    How I can update the local database structure without lose all the data?

    For example Is it possible to execute just an alter table to the database

    in order to manage this new field from the app after an simple update?

    Thanks in advanced for any help.


    Tuesday, July 29, 2014 7:38 AM


  • There can  be multiple approaches, like

    a) With new update create a new SQLite DB file (a new name like appdata_v1.1.db) and as a user launches app implement some data migration code from old db file for first time launch after upgrade. Once this is done successfully you may simply delete the old DB file. Existence of old DB file while app is launched will tell you that migration is not done yet.

    b) If you want to continue to use same DB file then you can simply create new tables in same DB file and issue alter table commands to add/modify columns. Refer SQLite documentation for this. Here you will have to first query SQLite database metadata to ensure you only do things if they do not exist in DB.

    Beyond this your solution depends on what SQLite client-ORM you are using, for example SQLite-Net.

    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    Tuesday, July 29, 2014 6:50 PM