-
Notifications
You must be signed in to change notification settings - Fork 1
/
HttpDataBaseLifecycle.kt
34 lines (29 loc) · 1014 Bytes
/
HttpDataBaseLifecycle.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.manna.monitor.room
import android.app.Application
import android.content.Context
import android.util.Log
import androidx.room.Room
import com.google.auto.service.AutoService
import com.manna.monitor.room.db.HttpDataBase
import com.manna.monitor.stone.lifecycle.ApplicationLifecycle
/**
* add google [@AutoService] annotation,to implementation it
* Init Room.databaseBuilder
*/
@AutoService(ApplicationLifecycle::class)
class HttpDataBaseLifecycle : ApplicationLifecycle {
override fun onAttachBaseContext(context: Context) {
//do somethings
}
override fun onCreate(application: Application) {
Log.d("Monitor", "Init room database and dao impl")
val dataBase =
Room.databaseBuilder(application, HttpDataBase::class.java, "monitor_network.db")
.build()
HttpDataDaoProvider.setHttpDataDao(dataBase.httpDataDao())
}
override fun priority(): Int {
//see also [ApplicationLifecycleProxy]
return 4
}
}