Saving Data on Android


Listening for child events



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

Listening for child events
Previously you saw how to use value event listener. Often you'll also need to know 
about changes in children of a specific node. In that case, you'll need to use a child 
event listener. Child event listeners notifiy the app when child nodes are added, 
deleted or moved within a parent node. To add a child event listener you'll need to 
call 
addChildEventListener()
 on a database reference instance, and there are four 
methods that you'll need to implement. Check the official documentation 
https://
firebase.google.com/docs/database/android/lists-of-data#child-events
 to learn more 
about child events.
Indexing
There can be a performance issue if your app frequently queries the database. To 
improve query performance you should consider defining indexing rules.  A database 
index is a data structure which is used to quickly locate and access the data in a 
database.
You can learn more about indexing data in the official documentation 
https://
firebase.google.com/docs/database/security/indexing-data
.
Saving Data on Android
Chapter 13: Reading to & Writing from Realtime Database
raywenderlich.com
229


Key points

FirebaseDatabase
 object is the main entry point to the database

DatabaseReference
 class represents a particular location in the database and it is 
used to refer to the location in the database to which you want to write to or read 
from.

push()
 method is used to create an empty node with an auto-generated key.
• Firebase Realtime Database has several types of listeners, and each listener type 
has a different kind of callback.

ValueEventListener
 listens for data changes to a specific database reference.

ChildEventListener
 listens for changes to the children of a specific database 
reference.
• You need to decide how to handle listeners when the user is not actively 
interacting with the app. In most cases, you want to stop listening for updates. To 
do that you need to remove the listener.
• For updating data in Realtime Database, the  
setValue()
 method is used.
• You can delete data by using the 
setValue
 method and specify 
null
 as an 
argument or you can use 
removeValue()
 method which will set the value at the 
specified location to 
null
.
• A query is a request for data or information from a database. 
Query
 class is used 
for reading data and it has many useful methods that allow you to fetch the data in 
a way you want.
• A database transaction is a unit of work that is independently executed and it 
must be atomic, consistent, isolated and durable.
• To improve query performance you should consider defining indexing rules.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   225   226   227   228   229   230   231   232   ...   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