android room always display closed in database inspector

Viewed 537

I am trying to use Database Inspector in Android Studio.

When I run the app on the device, inspector always showing my application database

enter image description here

Is there anything I need to set before using it? I am not using db.closed()

And here is my database module code

@Database(entities = [User::class], version = 1, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {

    abstract fun userDao(): UserDao

    companion object {
        //For singleton instantiation
        @Volatile private var instance: AppDatabase?= null

        fun getInstance(context: Context): AppDatabase {
            return instance ?: synchronized(this) {
                instance ?: buildDatabase(context).also { instance = it }
            }
        }

        private fun buildDatabase(context: Context): AppDatabase {
            return Room.databaseBuilder(context, AppDatabase::class.java, DATABASE_NAME)
                .addCallback(
                    object : RoomDatabase.Callback() {
                        override fun onCreate(db: SupportSQLiteDatabase) {
                            super.onCreate(db)
                        }
                    }
                ).fallbackToDestructiveMigration()
                .build()
        }

    }
}
0 Answers
Related