android - Clear Data on update -


i'm maintaining long living app on android, , i've decided change data model behind merging few sqlite databases single new one.

the thing is, if create new db , stop using old ones, every app user out there still have old sqlite files in local storage.

is there way force "clear data" upon new version of app? (i'm looking "right" way it, know can check if new db exists , act according, think there may better way)

thanks

whenever database needs upgraded(when user downloads new version of app, example), change in database version number calls onupgrade() method, can override thiis method provided sqliteopenhelper class:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     log.w("taskdbadapter", "upgrading version "+oldversion             +" "+newversion             +", destroy old data");     (string string : table_names)             db.execsql("drop table if exists "+ string);     oncreate(db); } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -