Не записываются данные из Firebase Realtime Database в TextView
private fun getNameDataFromDb() {
val currentUser = Firebase.auth.currentUser
val ref = databaseReference?.child(currentUser?.uid.toString())?.child("name")
val listener = object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
val changedDatas = snapshot.getValue(Name::class.java)
nameTextView.text = changedDatas?.name
}
override fun onCancelled(error: DatabaseError) {
Log.w("MyApp", "Failed to read value.")
}
}
ref?.addValueEventListener(listener)
}
Класс Name:
package com.example.heartbeatapp
class Name(val name: String = "") {
constructor() : this("")
}