Saving Data on Android


Alt + Enter  on  Windows or  Option + Enter



Download 19,28 Mb.
Pdf ko'rish
bet164/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   160   161   162   163   164   165   166   167   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

Alt + Enter
 on 
Windows or 
Option + Enter
 on Mac.
As previously mentioned, 
LiveData
 is an observable wrapper around a piece of data. 
Because of this, you can hold anything within it, like a list, array or a list of lists of 
lists... you get the point!
So, to use 
LiveData
, you need to wrap the object that you want to observe for 
changes, which in this case are the results of 
getAllQuestions()
 and 
getQuestionsAndAllAnswers()
. Now, every time the data in Room changes, for 
example by adding a new 
Question
, your 
LiveData
 and its observers will be notified, 
with the new information. But, if you keep calling to the DAO, you'll always get a new 
LiveData
, and this defeats the purpose of Room being observable.
Additionally, you should never talk to the DAOs directly, because it's easier to modify 
the code for internal database communication if you wrap it around another layer of 
abstraction. For this reason. you will create a 
Repository
 that acts as a bridge 
between your DAOs and the 
ViewModel
s, which you will define later.
Saving Data on Android Chapter 9: Using Room with Google's Architecture Components
raywenderlich.com
152



Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   160   161   162   163   164   165   166   167   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish