1. Download our Official Android App: Forums for Android!

Apps How to update database after app update

Discussion in 'Android Development' started by behrapps, Feb 17, 2011.

  1. behrapps

    behrapps Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Dec 15, 2010

    Dec 15, 2010
    10
    0
    15
    I have an app that I am developing that has a SQLLite DB that I have already created in the assets folder and when my dbprovider starts up it looks to see if the database is loaded into memory and if not writes the file to the databases folder. My problem is if I ever need to update the database, I would just do an app update with the new db in the assets folder. My question is how can I write my code to now when the dbprovider starts up that the db has changed? I can view the date/time of the db in the databases folder but haven't found a way to find the same for the db in the assets folder. Does anyone know a way to do this or even just a way for my app to know it has been updated and clear out the databases folder the first time it loads after the update? I don't want to put the db on the web because this db will rarely ever get updated and I wanted my app to not require internet since it is a business app. Any help would be appreciated.
     

    Advertisement

  2. idavis

    idavis Newbie
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    Feb 11, 2011

    Feb 11, 2011
    27
    4
    16
    I put in a table that I update with a row that contains a version level for the DB. I store the 'current' db level as a variable in the program. When I start initially, the table gets created and the current level is recorded. On later startups with a new version of the code, it pulls the db level in the database, and if it doesn't match, then I run a block of code to update the db to the current level.
     

Share This Page

Loading...