'How to read the data from firebase realtime database and display it in textview

I want to read the data from firebase and display it inside text views. I have used get().addOnSuccessListener, but the data is not displayed in the app. The data and the children do exist in the firebase.

database = FirebaseDatabase.getInstance().getReference("year_3")
    database.child("19ITR082").get().addOnSuccessListener {

            val name = it.child("name").value
            val adhaarno = it.child("adhaar").value
            val age = it.child("age").value
            binding.name.text = name.toString()
            binding.adhaarno.text = adhaarno.toString()
            binding.age.text = age.toString()

    }.addOnFailureListener{

        Toast.makeText(this,"Failed",Toast.LENGTH_SHORT).show()


    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source