Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet266/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   262   263   264   265   266   267   268   269   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

read
 and 
write
 access.
4. Add 
google-service.json
 to both 
starter
 and 
final
 projects.
To see how to do this, go back to 
"Chapter 11: Firebase Overview"
 and _"Chapter 
12: Introduction to Firebase Realtime Database"_.
Be sure to use the starter project from 
this chapter
, by opening the 
reading-
data-from-cloud-firestore
 folder and its 
starter
 project from the 
projects
raywenderlich.com
260


folder, rather than continuing with the final project you previously worked on. 
It has a few things added to it, including placeholders for the code to add in 
this chapter.
Reading data
Like the Realtime Database, Firestore allows to read data once, or to listen for data 
changes in real-time.
To get the data once, you need to call 
get()
 on the collection reference from which 
you want to read the data or you can also use 
get()
 on the document reference, if 
you need to read data from a specific document. For example, this is how you'd read 
the data from the 
posts
 collection:
database.collection(
"posts"

    .
get
() 
    .addOnSuccessListener { result -> 
      ... 
    } 
    .addOnFailureListener { exception -> 
      ... 
    }
Since getting the data is asynchronous, you need to attach a listener that will notify 
you when the data fetching is complete. It returns the data as a 
QuerySnapshot

QuerySnapshot
 is a class that contains the results of a query and can contain 
QueryDocumentSnapshot
 objects if they are available. A 
QueryDocumentSnapshot
 
contains data read from a document in your Firestore database. You'll see an 
example of this shortly.
Since you want that your app always has the latest data you won't fetch the data only 
once. Instead, you'll implement a listener, so you can receive events when the data 
changes.

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   262   263   264   265   266   267   268   269   ...   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