Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet233/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   229   230   231   232   233   234   235   236   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

Caching data locally
To enable disk persistence, you only need one line of code. Open 
WhatsUpApplication
 class and  enable persistence on the 
FirebaseDatabase
 
instance in the 
onCreate
 method:
override
 fun onCreate() { 
    
super
.onCreate() 
    
FirebaseDatabase
.getInstance().setPersistenceEnabled(
true

}
Turn on the network connection on your device. Build and run your app. Your posts 
will appear on the home screen. Now, disconnect your mobile phone from the 
network, close the app and kill the app process from the 
Recent apps
 menu. Run 
your app again. You'll see the posts appearing on the home screen.
Setting the 
setPersistenceEnabled
 method argument to 
true
 enables the app to 
store the data to the devices local storage — the disk. That is what makes the data 
available even after you kill the app.
Saving Data on Android
Chapter 14: Realtime Database Offline Capabilities
raywenderlich.com
233


The reason you had to enable disk persistence in the 
Application
 class, instead of 
the 
RealtimeDatabaseManager
, is that 
setPersistenceEnabled
 method needs to 
be called once per app and before creating the first database reference.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   229   230   231   232   233   234   235   236   ...   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