I need to retrieve the "administrator" value from Firebase
This is the code I use:
FirebaseDatabase.getInstance().getReference("/restaurants/$restaurantUID/administrator")
.get().addOnSuccessListener {
Log.d("key", it.toString())
}
The result in the log is this though:
2022-09-05 17:07:32.271 2885-2885/com.example.menuapp D/key: DataSnapshot { key = administrator, value = null }
How can I get the actual value for "administrator" and not a null?
2
Answers
Try this –
According to your last comment, I see that value of
restaurantUID
is:Which is totally different than the one in the database. The one in the database strats with "c20f02b0-…", hence that null for the value of
administrator
filed. If you want to get the correct value, then always make sure you’re reading the data on the correct path: