2013年7月19日星期五

Android sqlite how to create multiple database tables? Great God help you!

I want to create multiple database tables at once, but why only create the first run to the second, when the program is strong back then?
public class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper (Context context, String name, CursorFactory factory,
int version) {
/ / Must be super call the parent class constructor which
super (context, name, factory, version);
/ / TODO Auto-generated constructor stub
}
@ Override
public void onCreate (SQLiteDatabase db) {
/ / TODO Auto-generated method stub
db.execSQL ("create table table1 (name varchar (20), pw varchar (20))");
db.execSQL ("create table table2 (id int, a long, b long, c long)");
db.execSQL ("create table table3 (id int, a long, b long, c long)");
db.execSQL ("create table table4 (id int, a long, b long, c long)");
db.execSQL ("create table table5 (id int, a long, b long, c long)");
db.execSQL ("create table table6 (id int, a long, b long, c long)");
}
@ Override
public void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
/ / TODO Auto-generated method stub
}
}
-------------------------------------------------- ------------------------
Can you first run so many statements have not tried
-------------------------------------------------- ------------------------
Not only execute the first db.execSQL ("create table table1 (name varchar (20), pw varchar (20))");
Run the next one on the line when the program back!
-------------------------------------------------- ------------------------
Should not be the problem, and I tried to put int to integer, or not, and if only one db.execSQL ("create table table (id int, name varchar (20), pw varchar (20))"); it is running correctly!
-------------------------------------------------- ------------------------
Statement last face with a semicolon on it, the second can be executed successfully.
-------------------------------------------------- ------------------------

没有评论:

发表评论