I believe there is no Room API to access the database version programatically.
But, you can use this trick.
Create a singleton object class (Kotlin) to store the database version.
object App { const val DATABASE_VERSION = 1}
Specify the database version using the App
singleton object.
@Database(entities = arrayOf(...), version = App.DATABASE_VERSION)@TypeConverters(...)abstract class AppDatabase : RoomDatabase() { ...}
Now you can access the database version anywhere.
App.DATABASE_VERSION