LibreTube/app/src/main/java/com/github/libretube/db/DatabaseHolder.kt

20 lines
452 B
Kotlin
Raw Normal View History

2022-08-14 13:29:05 +05:30
package com.github.libretube.db
2022-08-13 23:34:07 +05:30
import android.content.Context
import androidx.room.Room
2022-09-08 22:11:57 +05:30
import com.github.libretube.constants.DATABASE_NAME
2022-08-13 23:34:07 +05:30
object DatabaseHolder {
2022-08-14 13:29:05 +05:30
lateinit var db: AppDatabase
2022-08-13 23:34:07 +05:30
fun initializeDatabase(context: Context) {
2022-08-14 13:29:05 +05:30
db = Room.databaseBuilder(
2022-08-13 23:34:07 +05:30
context,
AppDatabase::class.java,
DATABASE_NAME
2022-08-14 01:33:11 +05:30
)
2022-08-14 20:06:18 +05:30
.fallbackToDestructiveMigration()
2022-08-14 01:33:11 +05:30
.build()
2022-08-13 23:34:07 +05:30
}
}