Updating model with DBFlow

帅比萌擦擦* 提交于 2019-12-11 05:57:37

问题


I'm using the ORM DbFlow in my app, and i changed a column in a table class.

To get the DBFlow internal classes rebuilt with the new column, I tried incrementing the database version but the ****_Table class that we use in the queries hasn't been updated and still has the columns of the previous version.

@Database(name = MyDatabase.NAME, version = MyDatabase.VERSION)
public class MyDatabase {

public static final String NAME = "Releves";
//incremented the database version from 2 to 3
public static final int VERSION = 3;

Do you know how to make it do the update so i can make my query ?

Thank you


回答1:


Possible reason is that classes auto generated by dbflow might be still present, Try clean and rebuild the project - if this did not work, try invalidate cache and restart (File -> Invalidate cache and restart)




回答2:


class1:

public class DatabaseDBFlow extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }

Manifest--> android:name=".DatabaseDBFlow"

class2:

@Database(name = AppDatabase.NAME, version = AppDatabase.VERSION)
public class AppDatabase {
    public static final String NAME = "AppDatabase";

    public static final int VERSION = 1;
}

and class Database:

@Table(database = AppDatabase.class)
public class InformationDB_Theme extends BaseModel {

    @PrimaryKey(autoincrement = true)
    public int ID;
    @Column
    public String NAME;
}


来源:https://stackoverflow.com/questions/45916708/updating-model-with-dbflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!