I have two separate tables for my application, one is called users and the other is called passwords.
Users:
@Entity(tableName = "users")
public class Users {
// some setters and getters here
}
Passwords:
@Entity(tableName = "passwords")
public class Passwords {
// some setters and getters here
}
And this is how I'm accessing the database:
usersdb = Room.databaseBuilder(this, Users.class,"mymaindb")
.allowMainThreadQueries()
.build();
// Then later in some other activity when I need to use passwords table
passwords = Room.databaseBuilder(this, passwords.class,"mymaindb")
.allowMainThreadQueries()
.build();
The issue I'm having is that after a fresh install, when I access passwords then I can't access users or vice versa.
I get the following error:
Caused by: java.lang.IllegalStateException: 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.
But when I try to have two separate databases like passwords_db and users_db instead of mymaindb, then it works completely fine.
So is there a way I can have multiple tables under one database? If so, what am I doing wrong then? Thanks in advance!