I know there are lot of questions asked on Firebase Datasnapshot, but still i'm little unclarified about my doubt. Here is the thing,
I've data structer like this in Firebase Realtime database,
If i have a 100kb file inside the above reference say,
val ref = FirebaseDatabase.getInstance().getReference("Groups")
If i call
`
ref.addValueEventListener(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
}
override fun onDataChange(p0: DataSnapshot) {
// access getvalue here
}
})
`
I get a snapshot of data inside the reference as p0.
Question-1
Will this particular snapshot has all the available data inside the reference (will this downloaded snapshot size is 100kb?). If i cut the internet at the first line on onDataChange, can i be able to access all the data inside datasnapshot Or Will the data be downloaded only when i call p0.getValue
command on onDataChange & datasnapshot is just like data reference?
Question-2
In my code i've put a ValueEventListener on "Groups", so if there is a single change in the person2 activity(either new activity is added or existing data is modified), I'm downloading the entire data in the "Groups", which i wanted to avoid as the groups become larger more data is consumed. How to effectively get data from only person2 when person2 data modified or new activity added. I've tried adding child event listener to "Groups", which behaves same as ValueEventListener. I can't add listener for each person as the number of persons are unknown and it can be a larger number, i dont wan't that many listener in my code. My code is in production already so i can't even change the database structure.