搜尋

首頁  >  問答  >  主體

android - 关于SQLite数据库:SQLiteOpenHelper的构造函数参数VERSION。

/*public class TanngoBaseHelper extends SQLiteOpenHelper {

private static final int VERSION = 1;
private static final String DATABASE_NAME = "tanngoBase.db";

public TanngoBaseHelper(Context context) {
    super(context, DATABASE_NAME, null, VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {

    db.execSQL("create table" + TanngoTable.NAME + "(" +
            " _id integer primary key autoincrement," +
            TanngoTable.Columns.UUID + "," +
            TanngoTable.Columns.WORD + "," +
            TanngoTable.Columns.MEAN + "," +
            TanngoTable.Columns.DATE + "," +
            TanngoTable.Columns.SOLVED +
            ")"
    );
}

@Override
public void nUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}

}*/
public class TanngoBaseHelper extends SQLiteOpenHelper {

private static final int VERSION = 2;
private static final String DATABASE_NAME = "tanngoBase.db";

public TanngoBaseHelper(Context context) {
    super(context, DATABASE_NAME, null, VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {

    db.execSQL("create table " + TanngoTable.NAME + "(" +
            " _id integer primary key autoincrement, " +
            TanngoTable.Columns.UUID + ", " +
            TanngoTable.Columns.WORD + ", " +
            TanngoTable.Columns.MEAN + ", " +
            TanngoTable.Columns.DATE + ", " +
            TanngoTable.Columns.SOLVED +
            ")"
    );
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}

}

巴扎黑巴扎黑2772 天前773

全部回覆(2)我來回復

  • 大家讲道理

    大家讲道理2017-04-17 17:53:51

    那個VERSION標識了目前資料庫版本,可以在onUpgrade中進行資料庫欄位的修改和擴充。

    回覆
    0
  • PHP中文网

    PHP中文网2017-04-17 17:53:51

    VERSION代表了資料庫的版本,在更新資料庫的時候改變。 可能會有軟體版本不同 他們的資料庫版本也是不同的,資料庫裡的欄位也是不同的

    回覆
    0
  • 取消回覆