摘要:SQLiteOpenHelper.execSQL()一次只能Create一個Table
先前寫Android遇到的情況:
private static final String gTb_CREATE_Data =
"CREATE TABLE [test] ("
+ "[t1] TEXT NOT NULL PRIMARY KEY,"
+ "[t2] TEXT NOT NULL);"
+"CREATE TABLE [img] ("
+ "[imgName] TEXT NOT NULL, [imgLink] TEXT NOT NULL);";
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(gTb_CREATE_Data);
}
catch (Exception e)
{
Log.d("File_Read", e.getMessage());
}
} //
卻出現找不到Table [img]的錯誤訊息...
猜測是execSQL()一次只能Create一個Table,
於是將兩個Table的Create指令分別在兩個execSQL()執行
問題即解決...
--
不斷學習,精進自我
Herbert Fang