database - How to create more than one table in sqlite in android? -


i have 3 tables in db. try out many sample regarding creating db in sqlite, , works out find of them 1 table only....

i try many ways execute queries db.execsql(query) create each table in oncreate errors ..

so strategies create more 1 table??? should create many class represent each table extends sqliteopenhelper???

thx

here part of class extends sqliteopenhelper

public void oncreate(sqlitedatabase db) {     // todo auto-generated method stub     try{         db.execsql(create_table_1);         db.execsql(create_table_2);         db.execsql(create_table_3);     }catch( exception e){         log.e("dbadapter", e.getmessage().tostring());     }  } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     // todo auto-generated method stub     db.execsql("drop table if exists " + table_1);     db.execsql("drop table if exists " + table_2);     db.execsql("drop table if exists " + table_3);     oncreate(db); } 

it seems table2, , table3 not create cuz when insert data table 2 error - no such table2 found !!!

here created table string:

//create script patient public static string create_table_1= "create table " + table_user + " (" + user_id + " integer primary key autoincrement, " + user_name + " text not null, " + device_key + " text not null  );" ;  public static string create_table_2= "create table " + table_gps_setting + " (" + settin + " integer primary key autoincrement, " + refresval + " long not null, " + ode + " varchar(20), " + _type + " varchar(20) );" ;  public static string create_table_3= "create table " + table_w + " (" + gpd + " integer primary key autoincrement, " + litude + " double, " + litude + " double, " +  atude + "integer,"+ m + "integer,"+ dtion + "integer,"+ dance + "integer,"+ ldd + "integer,"+ sesid + "double,"+ acccy + "double,"+ tmp + "long,"+ tate + "text,"+ d_id + "text);" ; 

any idea?

you can create many table want this.

 db.execsql(table1);  db.execsql(table2); 

where table1 string containing table creation command

problem trying create table after creating database.uninstall application , run sql statements create tables in database.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -