What kind of approaches needed to add the total amount of rating value in firebase? Here i have included the json structure of my firebase. The one needed to be focused on are ratingstar_review.
Supposedly, the sum of ratingstar_review from first list and second would be 3+5=8. So I would expected to get that total sum 8. Below is the code for retrieving data from firebase to be stored on ratingbar for display.
starRef.child("number_rating").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot != null && dataSnapshot.getValue() != null) {
float rating = Float.parseFloat(dataSnapshot.getValue().toString());
star.setRating(rating);
}
}
@Override
public void onCancelled(DatabaseError databaseError) { }
});
An example would be a helpful. Thank you!
Something like this should do the trick:
The main differences with your code:
/Ratings
the code needs to loop over these children.getChild("ratingstar_review")
and then get it as an integer withgetValue(Integer.class)
.