1、设置一个DB_VERSION
public static final int DB_VERSION = 12、当你要更新表的时候就把DB_VERSION+1,就会触发onUpgrade,数据库就更新了,记得采纳
public DBHelper() {// for test
daoConfig = new DbManager.DaoConfig()
.setDbName(DB_NAME)
.setDbVersion(DB_VERSION)
.setDbDir(Environment.getExternalStorageDirectory())
.setDbOpenListener(new DbManager.DbOpenListener() {
@Override
public void onDbOpened(DbManager db) {
db.getDatabase().enableWriteAheadLogging()
}
})
.setDbUpgradeListener(new DbManager.DbUpgradeListener() {
@Override
public void onUpgrade(DbManager db, int oldVersion, int newVersion) {
updateTable(db, xx.class)
}
})
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)