Android SQLite Adding User Defined Table Names to a Pre Made Database -


this first post forgive me if i've done wrong. have database in assets folder bring app on start up, can make new table running code in onupgrade (as long versions don't match).

if(oldversion < 2){ db.execsql("create table if not exists " + workoutslist.database_table_dynamic + " (" +                     workoutsdbadapter.workouts_row_id + " integer primary key autoincrement, " +                     workoutsdbadapter.workouts_name + " text not null, " +                     workoutsdbadapter.workouts_weight + " decimal not null, "+                     workoutsdbadapter.workouts_sets + " int not null, "+                     workoutsdbadapter.workouts_reps + " int not null);");} 

i run code clicking on button

    btnupdate.setonclicklistener(new view.onclicklistener() {          public void onclick(view arg0) {             string table = tablename.gettext().tostring();             database_table_dynamic = table;             if (table.trim().length() > 0) {             dbhelper.addtable();             }             else{                 toast.maketext(getapplicationcontext(), "please enter table name",                     toast.length_short).show();             }         }       }); 

dbhelper.addtable(); increments database version 1. (it used else that's why name miss leading). possible onupgrade run button pressed (as dbhelper.addtable(); run, because right database updates once view information using method) feedback on method of doing , other ways recommend appreciated i'm new this. thanks!

onupgrade() called when initialize sqliteopenhelper new version.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -