android - Insert values into SQLite Database -
is there easier way can insert data in table in sqlite? need insert state_id , state_name in table tblstate. since there lot of state in us, there way can use instead of this:
string row1 = "insert tblstate values (1,'alabama')"; string row2 = "insert tblstate values (2,'alaska')"; string row3 = "insert tblstate values (3,'california')"; db.execsql(row1); db.execsql(row2); db.execsql(row3);
thanks!
try this..
string state[] = { "state1" , "state2",.............}; int id=1; for(int i=0;i<state.length;i++) { db.execsql("insert tblstate values (id,state[i])"); id++; }
Comments
Post a Comment