Room Database setup
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package ac.aux.compose
|
||||
|
||||
import android.content.Context
|
||||
|
||||
actual class PlatformContext(
|
||||
val applicationContext: Context
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
package ac.aux.compose.database.builder
|
||||
|
||||
import ac.aux.compose.PlatformContext
|
||||
import ac.aux.compose.database.AuxDatabase
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
actual object PlatformDatabaseBuilder {
|
||||
actual fun getDatabaseBuilder(platformContext: PlatformContext): RoomDatabase.Builder<AuxDatabase> {
|
||||
val appContext = platformContext.applicationContext
|
||||
|
||||
val dbFile = appContext.getDatabasePath("aux.db")
|
||||
return Room.databaseBuilder<AuxDatabase>(
|
||||
context = appContext,
|
||||
name = dbFile.absolutePath
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user