11/30/2020

Room database with multiple different entities

I searched for a long time to find the answer to my question of how to create a Room Database in Android Studio with multiple entities (a.k.a. model classes). While making an app, I came across the point that "Each RoomDatabase instance is fairly expensive, and you rarely need access to multiple instances within a single process.(source)

But I finally found this:

Incrementally migrate from SQLite to Room, which has an example that describes that the entities are entered as a list.

E.g. the beginning of the Database.java:

@Database(entities = {list goes here}, version = 1)

No comments: