我遵循了使用Android构建数据库的标准教程。我创建了一个名为dbhelper的类,它扩展了sqliteOpenHelper。我重写了创建处理程序来执行字符串。
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DbDefinitions.DB_CREATE);
}
dbdefinitions.db_create是我创建的静态字符串。
public static final String TABLE_MESSAGES = "messages";
public static final String TABLE_FRIENDS = "friends";
public static final String STATE_OK = "STATE_OK";
public static final String DB_CREATE =
"create table " + TABLE_MESSAGES + " (_id integer primary key, user_id integer not null, created_on integer, subject text not null, summary text not null, messagetext text null, read integer not null, status text not null default '" + STATE_OK + "'); " +
"create table " + TABLE_FRIENDS + " (_id integer primary key, user_id integer not null, friend_id integer not null, created_on integer, status text not null default '" + STATE_OK + "');";
我想使用1个字符串来执行多个SQL语句。如果sqliteDatabase.execsql只允许1条语句,我该怎么做?