原本只有4個欄位,後來新增2個欄位跟修改1個欄位之後就跑不出來了,剩原本那兩個欄位可以新增,有爬文照著新增,但不知道哪裡寫錯,請大老們幫看看!!
public class DBHelper extends SQLiteOpenHelper {
private final static int DBVersion = 3;
private final static String DBName = "SampleList.db";
private final static String TableName = "MySample";
public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
int version) {
super(context, name, factory, version);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
String SQLTable = "CREATE TABLE IF NOT EXISTS " + TableName +
"(" +
"_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"Name TEXT," +
"Phone TEXT," +
"BloodType TEXT," +
"Birthday TEXT," +
"Address TEXT," +
"ElseInfo TEXT" +
");";
db.execSQL(SQLTable);
// 產生資料表的 SQL 寫在這 onCreate
// 如果 Android 載入時找不到生成的資料庫檔案,就會觸發 onCreate
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
final String SQL = "DROP TABLE " + TableName;
db.execSQL(SQL);
// onUpgrade 則是如果資料庫結構有改變了就會觸發 onUpgrade
}