I have the following code that splits or remove characters after a particular symbol:
rating = rating.split("\s*=\s*")[0];
I am also wondering if there is a way to add the rating numbers up for each Medical Clinic? I have a child by the name of Rating and another child called rating by username... I am trying to call the getUID, I am assuming that this will return all the users who have submitted the rating and by using the split method, I could add the rating up? Can I also show the Medical Clinic with the highest rating first? I did try to use orderbychild("Rating") but it is showing the Medical Clinics with the least rating first. I guess, I haven't added the rating yet...
DatabaseReference reference = FirebaseDatabase.getInstance().getReference(); // getReference() is the root
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
list.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
String rating = email.split("\\s*@\\s*")[0];
System.out.println(rating);
int rate = (int) snapshot.child("Rating by" + rating).getValue();
// rating.substring(rating.indexOf("=")+1);
// String rating = rating.Substring(rating.IndexOf('.') + 1);
// rating = rating.replaceAll("[^\\d.]", "");
Information info = snapshot.getValue(Information.class);
assert info != null;
String txt = "Medical Clinic" + info.getName() + "Rating" + rate;
list.add(txt);
// System.out.println(rating);
// list.add(snapshot.getValue().toString());
}
adapter.notifyDataSetChanged();
}
I also need to find a way to remove all characters before the = sign....