I want to get all list of restaurants from Firebase in android.
Here is my code:
boolean delivery;
String openTime, closeTime, restaurantName;
long
Kotlin Example
This is a example to get all your nested data out of firebase real time database.
There are many tokens in this example and every token contains list of notes
val noteListener = object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
// For each loop will run until all notes are fetched
for (snapshot in dataSnapshot.children){
val note = snapshot.getValue(Note::class.java)
Log.e("Note",note?.title)
}
}
override fun onCancelled(databaseError: DatabaseError) {
// On failed, log a message
Log.e("Debug", "loadPost:onCancelled", databaseError.toException())
}
}
//You can use the addListenerForSingleValueEvent() method to simplify this scenario: it triggers once and then does not trigger again.
//ref.child(token) is the path for reach notes for each unique user , in your case it can be ref only
ref.child(token).addListenerForSingleValueEvent(noteListener)