我在我的项目“ActiveAndroid”中使用。我有一个模型,我保留。这是一个模型:
@Table(name="Params")
public class Params extends Model {
public Params() {
super();
}
@Expose
@Column(name="height")
@SerializedName("heigth")
public int heigth;
@Expose
@Column(name="weight")
@SerializedName("weight")
public int weight;
}
这里全部保存:
public void success(User user, Response response) {
user.params.save();
user.save();
ActiveAndroid.clearCache();
}
一切正常!但是如果我想在模型中添加另一个字段:
@Expose
@Column(name="strong")
@SerializedName("strong")
public int strong;
我收到一个错误:
android.database.sqlite.SQLiteException: table Params has no column named strong (code 1): , while compiling: INSERT INTO Params(Id,weight,height,strong) VALUES (?,?,?,?)
我当然知道为什么会出现这个错误。因为表中没有这样的列。这就是问题,如何添加此列???
现在我已经尝试过:
完全删除程序,再次编译,运行,一切正常!因为它从该列创建了一个新表。
尝试更改清单数据库中的版本,但这并没有成功。
我知道在升级的方法中正常使用数据库可以更改数据库的版本和重组表。但是如何在 ORM "ActiveAndroid" 中做到这一点?