Comments (1)
@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)
- 您好,MVPArms 正常收集优秀的 MVPArms 学习项目 HOT 5
- 工程使用gradle:3.3.2编译报错 HOT 1
- 数据库 HOT 1
- 数据库导入问题 谢谢 HOT 1
- Https 你是怎么绑定证书? HOT 11
- 怎么通过AppComponent获取DaoSession实例 HOT 11
- ParameterInterceptor 的第63行报错 HOT 3
- 今天刚下载了大佬的项目,需要登入账号密码是什么呢 HOT 1
- 关于下载模块的建议 HOT 1
- AS从2.3.3版本升级到3.0.1版本后报错,有解决方案吗? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mvpframes.