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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -