What is the database name in the Room.databaseBuilder?

Viewed 825

Here is the official docs for Room Database. It contains the following code

val db = Room.databaseBuilder(
            applicationContext,
            AppDatabase::class.java, "database-name"
        ).build()

I was wondering what the "database-name" in the database builder does. What practical and tangible effects does it have?

1 Answers

Room is a Jetpack's wrapper on Sqlite DB. Sqlite holds data in single database file. So using "database-name" in Room's builder you'll get "database-name.db" file on filesystem.

In theory one app could deal with several SQLite databases. To switch between them you use different database names. If you have single database in your app its name isn't so crucial

Related