android - green dao update column on play store update has taken place -


this generator class

public class generator {     public static void main(string[] args) throws exception {         schema schema = new schema(1, "app.abc.db.dao");         createabcdb(schema);      }     private static void createabcdb(schema schema) throws ioexception, exception {         entity abc = schema.addentity("abc");         abc.addidproperty();         abc.addshortproperty("name");     } } 

this code abc dao dao session. works fine.

daomaster.devopenhelper devopenhelper = new daomaster.devopenhelper(surveyactivity.this, "abc.db", null);         sqlitedatabase db = devopenhelper.getwritabledatabase();         daomaster daomaster = new daomaster(db);         daosession daosession = daomaster.newsession(identityscopetype.none);         abcdao = daosession.getabcdao(); 

i added 1 more column

abc.addshortproperty("email"); 

to createabcdb in generator new version of app. once users updated getting sql exception saying no column found. because calling on new login

dropalltables(db, true); oncreate(db);  

but problem have given 1 time login user come landing screen on upgrade play store. don't know whether user upgraded app or not in order drop , create tables.

so question how know table has altered?

each time significant modification this, have update de schema version number:

schema schema = new schema(2, "app.abc.db.dao"); 

this way, in openhelper present in daomaster, or in sqliteopenhelper taht you're using, can control changes in onupgrade() function:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     log.i("greendao", "upgrading schema version " + oldversion + " " + newversion + " dropping tables");     dropalltables(db, true);     oncreate(db); } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -