0
0
Android Kotlinmobile~10 mins

Cloud Firestore integration in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get an instance of Firestore.

Android Kotlin
val db = FirebaseFirestore.[1]()
Drag options to blanks, or click blank then click option'
AgetInstance
Binitialize
Cconnect
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize()' instead of 'getInstance()'.
Trying to create Firestore with 'connect()'.
2fill in blank
medium

Complete the code to add a new document to the 'users' collection.

Android Kotlin
db.collection("users").[1](userData)
Drag options to blanks, or click blank then click option'
Aget
Bupdate
Cadd
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get()' which only reads data.
Using 'update()' which requires an existing document.
3fill in blank
hard

Fix the error in the code to listen for realtime updates on 'messages' collection.

Android Kotlin
db.collection("messages").addSnapshotListener { snapshots, [1] ->
    if (error != null) {
        return@addSnapshotListener
    }
    // process snapshots
}
Drag options to blanks, or click blank then click option'
Athrowable
Bexception
Cfailure
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exception' or 'error' which are not the parameter names here.
Using 'failure' which is not defined.
4fill in blank
hard

Fill both blanks to update the 'age' field of a document with ID 'userId' in 'users' collection.

Android Kotlin
db.collection("users").document(userId).[1](mapOf("age" to [2]))
Drag options to blanks, or click blank then click option'
Aupdate
Bset
C25
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set()' which replaces the whole document.
Using a wrong age value.
5fill in blank
hard

Fill all three blanks to query 'products' collection for items with price greater than 100 and order by price ascending.

Android Kotlin
db.collection("products").whereGreaterThan("[1]", [2]).orderBy("[3]")
Drag options to blanks, or click blank then click option'
Aprice
B100
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'price' for filtering or ordering.
Using a wrong number for comparison.