是否有可能(简单)获取当前数据库版本号,将其递增,然后从活动中将其传递给 SQLiteOpenHelper 的构造函数,而不是像这样对版本号进行硬编码?
活动(从 onclick 调用):
public void updatedb(){
//pseudo-code next 2 comments
//int incVersion = getCurrentDBVersion();<==question here
//incVersion = incVersion + 1;
DatabaseHandler dbincrement = new DatabaseHandler(this, incVersion);
}
SQLiteOpenHelper 扩展:
public class DatabaseHandler extends SQLiteOpenHelper{
public DatabaseHandler(Context context, int incVersion) {
super(context, DATABASE_NAME, null, incVersion);
}
}