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.

how update table schema after app upgrade on android?

how upgrade sqlite database in android?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -