android - Updating the database -


welcome.
database updated in way:

public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     if (newversion > oldversion) {         log.e("tag", "new database version exists upgrade.");          try {             log.e("tag", "copying database...");             copydatabase();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     }  } 

the problem have table in database of statistics, wanted order data in table copied new database.

how i? ask example.

regards , sorry poor english.


i tried this:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     if (newversion > oldversion) {         log.e("tag", "new database version exists upgrade.");          db.begintransaction();         try {             log.e("tag", "copying database...");             this.getreadabledatabase();             arraylist<statystyka> statystyki = getallstatistic();             copydatabase();             (int = 0; statystyki.size() >= i; i++) {                 addstat(statystyki.get(i).getid_pytania(),                         statystyki.get(i).getilosc_rozwiazan(), statystyki                                 .get(i).getilosc_poprawnych(), statystyki                                 .get(i).getilosc_blednych());             }             db.settransactionsuccessful();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }         db.endtransaction();     }  } 

but error:

java.lang.illegalstateexception: getreadabledatabase called recursively

how open database load data?

after upgrade of database, old tables still there need change new schema version. see this documentation.

for eg::
have add new column table ::

string alter_table_command=" alter table " + table_name + " add column " + new_column + " text; "; db.execsql( alter_table_command ); 

read alter table here.

note:: in case want copy table database use solution suggested @vipul above.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -