android - 关于SQLite数据库:SQLiteOpenHelper的构造函数参数VERSION。
巴扎黑
巴扎黑 2017-04-17 17:51:51
0
2
798

/*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) {
}

}

巴扎黑
巴扎黑

reply all(2)
大家讲道理

That VERSION identifies the current database version, and database fields can be modified and expanded in onUpgrade.

Ty80

VERSION represents the database version, which changes when the database is updated. There may be different software versions, their database versions are also different, and the fields in the database are also different

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template