android - calling onCreate method from inside another method -


i have never seen explicitly call 1 of system callback methods oncreate() or ondestroy() inside method. looks wrong. thought saw in example , can not believe it. imagination or real?

in code below onupgrade() method of sqliteopenhelper class, calling oncreate() method explicitly function. possible call oncreate() inside method? , there better way without calling oncreate()?

 private static class databasehelper extends sqliteopenhelper{       databasehelper(context context){          super(context, database_name, null, database_version);      }       @override      public void oncreate(sqlitedatabase db) {      db.execsql("create table if not exists " + table_name + " (" + lentitems.note_id + "id integer primary key autoincrement, " +                lentitems.title + " text, " + lentitems.text + " text);");       }       @override      public void onupgrade(sqlitedatabase db, int previousversion, int newversion) {      db.execsql("drop table if exists " + table_name);      oncreate(db); // <-- explicit call oncreate      }   } // end databasehelper inner class 

the call there correct, oncreate() called once when database first created. onupgrade called when database version changed. when drop table in onupgrade have call oncreate there create new table oncreate changed reflect new table.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -