Reputation: 3
W/ClassMapper: No setter/field for mobile found on class com.example.estateagentmapp.model.User (fields/setters are case sensitive!)
I had gotten this problem but not anymore.
I am using this to try and pull data from my firebase real-time database. But, I am unable to populate my text fields with it. what am I doing wrong?
here is the code I am doing it with and my user model. how do I fill in those textfields?
private fun getUserInfo() {
val uid = FirebaseAuth.getInstance().currentUser!!.uid
val ref = FirebaseDatabase.getInstance().reference
val uidRef = ref.child("users").child(uid)
val valueEventListener: ValueEventListener = object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val user = dataSnapshot.getValue(User::class.java)
user?.firstName == fname.toString()
user?.lastName == lname.toString()
user?.email == email.toString()
user?.mobile == mobile.toString()
user?.dateOfBirth == dob.toString()
}
override fun onCancelled(databaseError: DatabaseError) {
Log.d("error", databaseError.message)
}
}
uidRef.addListenerForSingleValueEvent(valueEventListener)
}
my model
data class User(val uid: String? = "",
val firstName:String = "",
val lastName:String = "",
val mobile:String ="",
val dateOfBirth:String ="",
val email:String = "",
val type: String = ""
) {
constructor() : this("", "", "", "", "", "", "")
}
My realtime db is like this
user
--uid
--firstName
--secondName
--mobileName
--dateOfBirth
--email
--type
Upvotes: 0
Views: 105
Reputation: 80924
The fields in the database must have the same name as the fields in the model class, therefore you need to change mobileName
to mobile
in your realtime database.
Upvotes: 0