Platon Malyugin
12/14/2020, 5:54 AMlateinit var aLiveData: LiveData<List<..>>
aLiveData = // define live data
val list = aLiveData.value
KayCee
12/14/2020, 5:58 AMakatkov
12/14/2020, 6:04 AMaLiveData.value
before you assign aLiveData = ...
Then it'll be null and crashakatkov
12/14/2020, 6:06 AMaLiveData
isn't guaranteed to be initialized before you use it, you should make it nullable insteadKayCee
12/14/2020, 7:26 AMaLiveData = getListFromDb()
yeah, thats right but in that case the " lateinit exception" will be presented not NPE? since there is no lateinit exception, so I think in my code the "getListFromDb()" return a null livedata? That seems unreasonable with the query:
@Query("SELECT * FROM table")
fun getListFromDb(): LiveData<List<DataA>>
Vampire
12/14/2020, 9:31 AM