Skip to content

Commit 5ed4dcd

Browse files
committed
Migrate downloads to DatabaseProvider
1 parent 6c57698 commit 5ed4dcd

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

downloads/downloads-impl/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies {
4343
implementation project(path: ':statistics-api')
4444
implementation project(path: ':app-build-config-api')
4545
implementation project(path: ':downloads-store')
46+
implementation project(path: ':data-store-api')
4647

4748
implementation AndroidX.core.ktx
4849

downloads/downloads-impl/src/main/java/com/duckduckgo/downloads/impl/di/DownloadsModule.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package com.duckduckgo.downloads.impl.di
1818

19-
import android.content.Context
20-
import androidx.room.Room
19+
import com.duckduckgo.data.store.api.DatabaseProvider
20+
import com.duckduckgo.data.store.api.RoomDatabaseConfig
2121
import com.duckduckgo.di.scopes.AppScope
2222
import com.duckduckgo.downloads.store.DownloadsDatabase
2323
import com.squareup.anvil.annotations.ContributesTo
@@ -31,9 +31,13 @@ class DownloadsModule {
3131

3232
@Provides
3333
@SingleInstanceIn(AppScope::class)
34-
fun provideDownloadsDatabase(context: Context): DownloadsDatabase {
35-
return Room.databaseBuilder(context, DownloadsDatabase::class.java, "downloads.db")
36-
.fallbackToDestructiveMigration()
37-
.build()
34+
fun provideDownloadsDatabase(databaseProvider: DatabaseProvider): DownloadsDatabase {
35+
return databaseProvider.buildRoomDatabase(
36+
DownloadsDatabase::class.java,
37+
"downloads.db",
38+
config = RoomDatabaseConfig(
39+
fallbackToDestructiveMigration = true,
40+
),
41+
)
3842
}
3943
}

0 commit comments

Comments
 (0)