android - ORMlite database version not incrementing after onUpgrade -


i've been working on android project , i've been using ormlite. far i've been able need , i'm using quite complex data model now.

now seems i'm having problems onupgrade method of helper.

here essentials of onupgrade method:

public void onupgrade(final sqlitedatabase db, final connectionsource connectionsource, int oldversion, final int newversion) { try {     // loop round until newest version has been reached , add appropriate migration     while (++oldversion <= newversion) {         // available update sql statements , execute them         final string[] availableupdates = sqlstaticcontenthelper.getmigrationstatements(oldversion);         executestatements(db, availableupdates, true);     }            } catch (exception e) {     log.e(log_tag, "onupgrade() - can't migrate databases, bootstrap database, data lost", e);     oncreate(db, connectionsource); } 

here oncreate method:

public void oncreate(sqlitedatabase database ,connectionsource connectionsource) {     try {     //create tables     (class<?> c : alltablesarray)     {         try {             tableutils.droptable(connectionsource, c, false);         } catch (sqlexception e) {log.d(log_tag, "oncreate() - not droping table " + c.getcanonicalname() + ". not exist.");}         tableutils.createtable(connectionsource, c);     }  } catch (exception e) {     log.e(log_tag, "oncreate() - problem creating tables : ", e);     throw new runtimeexception(e); }  

the expected behavior following:

  1. there upgrade
  2. do upgrade
  3. if upgrade not successful resources database
  4. increment version

i upgrades , works fine (when works fine). during tests inserted sql error on purpose , go oncreate , drops tables , creates tables, wont increment version (next time application restarted try upgrade again).

anyone got idea of why happening? if no exception occurs in onupgrade database version gets updated correctly.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -