I have just linked and started storing values in my realtime database and it all works smoothly. I have noticed however that when attempting to set another string to the list its overwrite it instead of having multiple values. My goal is to store multiple numbers (stored as strings) to the branch so I can calculate an average value to display in my app.
Here is current code:
val myRef = database.getReference("/general/$position") //sets location to save data, (In the section general, subcategory being the number of the list item being used
//set up button that is in the dialogue
val button = dialog.findViewById<View>(R.id.menu_rate) as Button
button.setOnClickListener {
val simpleRatingBar =
dialog.findViewById<View>(R.id.ratingBar) as RatingBar // initiates the rating bar
val ratingNumber = simpleRatingBar.rating // get rating number from a rating bar
Toast.makeText(this, "You rated this $ratingNumber stars!", Toast.LENGTH_SHORT).show()
val rating = ratingNumber.toString() //converts the float to string for storage
myRef.setValue(rating) //saves value to server
.addOnSuccessListener {
Toast.makeText(this, "success", Toast.LENGTH_SHORT).show()
}
}
Here is my database, how could I get all the number values without the keys so I can do calculations with them?
So how could I get multiple values to be stored and then retrieve just the values so that I can utilize them in my app?