Hey guys! I have just started learning kotlin. Bee...
# android
Hey guys! I have just started learning kotlin. Been using Flutter for an year but wanted to learn native as well. I was trying room library. Its recommended in docs to use singleton pattern with the database. So I thought that an object would be go to choice, however, I see everyone is using abstract class. Any reasons why?
You cannot create an instance of a database, instead, you should acquire it via 
Room.databaseBuilder(Context, Class, String)
Room.inMemoryDatabaseBuilder(Context, Class)
👍 1
In other words: the Room library will provide you with an instance that extends your abstract class. Treat this instance as a singleton, i.e.: keep reference to it and re-use that single instance
👍 1