Saving Data on Android


Ensures your UI matches your data state



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

Ensures your UI matches your data state
: Since 
LiveData
 implements the 
observer pattern, you can be sure that your UI widgets such as 
Button
s, 
ListView
s, 
RecyclerView
s or 
TextView
s will always be updated with the 
latest 
information
.

No memory leaks
: Since 
LiveData
 observers are bound to the lifecycle of other 
components, they will be destroyed as soon as the associated component is 
destroyed.

No crashes due to stopped activities
: When an 
Activity
 becomes 
paused
 or 
stopped
 it won't receive any new 
LiveData
 notifications.

No more manual lifecycle handling
: Google made sure that 
LiveData
 
components are lifecycle-aware by default, so you don't have to manually control 
them.

Proper configuration changes
: Since 
LiveData
 is lifecycle-aware, and it caches 
the latest piece of data emitted, your Android components will receive the last 
emitted state, after configuration changes.

Sharing resources

LiveData
 can be extended to wrap system services, so they 
can be shared in your app.
LiveData
 sounds awesome, right? Well, you are going to use it to wrap the results of 
your DAO queries, and as such, activities and fragments you use will automatically be 
notified of any changes. But, to do this, you need to add the 
LiveData
 dependency to 
your project, and change the DAO definitions, to return 
LiveData
s.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   157   158   159   160   161   162   163   164   ...   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