Giter Club home page Giter Club logo

Comments (1)

yougaohui avatar yougaohui commented on May 18, 2024

@database(entities = {User.class, Bus.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {

public abstract UserDao userDao();

public abstract BusDao busDao();

public static AppDatabase get(AppComponent component) {
    return (AppDatabase) component.dbManager().database();
}

}

@entity(tableName = "Bus")
public class Bus {
@PrimaryKey(autoGenerate = true)
private int ids;
@SerializedName("name")
String name;

public int getIds() {
    return ids;
}

public void setIds(int ids) {
    this.ids = ids;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

}

@entity(tableName = "User")
public class User {

@PrimaryKey(autoGenerate = true)
private int id;

// ID
@SerializedName("userId")
private String userId;

// 名字
@ColumnInfo(name = "name")
private String name;

// 排除这个字段,不存入数据库
@Ignore
Bitmap bitmap;

public User() {

}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getUserId() {
    return userId;
}

public void setUserId(String userId) {
    this.userId = userId;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public Bitmap getBitmap() {
    return bitmap;
}

public void setBitmap(Bitmap bitmap) {
    this.bitmap = bitmap;
}

}
我这样操作数据库,要抛出Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.这个异常。难道这个框架只能初始化一个类在AppDatabase 里面吗?可以qq联系你吗沟通一下这个心数据库的用法,我网上查了很多资料,都没发现什么原因导致的,有的说是数据库更新。感觉不是那么回事啊

找到原因了,原来数据库文件保存到sd卡根目录里面,没删除,我卸载后也删除不了,所以一直用的第一次初始化那个表的数据库,需要手动删除才行。

from mvpframes.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.