Rebuild SQLite database when app updates, Android -
i need rebuild sqlite database in app when users upgrade previous version have changed content of database, app checks if first run builds database save time on subsequent launches of app. when update app none of new info in database displays. there way check if app being updated instead of being installed first time? here code inserting data database:
boolean firstrun = getsharedpreferences("preference", mode_private).getboolean("firstrun", true); if (firstrun){ new alertdialog.builder(this) .settitle("welcome!") //set title text .setmessage(...) .setneutralbutton("ok", null).show(); //sets button type thread workthread=new thread(new runnable(){ public void run() { dbhelper.deleteallspeakers(); // clear database dbhelper.insertsomespeakers(); //add data runonuithread(new runnable(){ @override public void run() { mprogressdialog.dismiss(); toast.maketext(mainactivity.this, "done", toast.length_long).show(); myfilter.settext(""); } }); } }); workthread.start(); mprogressdialog=progressdialog.show(this, "loading", "building speaker database"); }
any appreciated.
you can use database version. pass database version using sqliteopenhelper. can refer following answers.
Comments
Post a Comment