I am trying to find some of the total prices from my collects but it seems there is a data mismatch somewhere I can't solve so if anyone can assist me to do so I will be thankful
val id = auth.currentUser?.uid.toString()
dref = FirebaseDatabase.getInstance().getReference("tempCart").child(id)
dref.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
if(snapshot.exists()){
for (cartSnapshot in snapshot.children){
val cart = cartSnapshot.getValue(CartData::class.java)
cartList.add(cart!!)
toto = cartSnapshot.child("totalPrice").getValue(Int::class.java)!!
toto += toto
}
orderCost.text = toto.toString()
cartRecycler.adapter = cartAdapter
}
}
override fun onCancelled(error: DatabaseError) {
TODO("Not yet implemented")
}
})
I have tried several times to fix it by reading the guides online they are changing the data from firebase to integer, but when I do so it tells me I cant cast java.lang.string
to int