Hi there i'm facing issue that FB realtime DB deletes old data while inserting a new one here is my code
String text = reviewText.getText().toString();
if (text.length() > 15){
int rating = (int) ratingBar.getRating();
String uuid = firebaseAuth.getCurrentUser().getUid();
Map<String, String> data = new HashMap();
data.put("rating", String.valueOf(Integer.parseInt(String.valueOf(rating))));
data.put("comment", text);
DatabaseReference db = firebaseDatabase.getReferenceFromUrl("dburl").child("attr_reviews").child(placename);
db.setValue(uuid).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
db.child(uuid).setValue(data).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
}else {
Toast.makeText(getActivity(), R.string.eReviewErrUnkw, Toast.LENGTH_LONG).show();
}
}
});
}else {
Toast.makeText(getActivity(), R.string.eReviewErrUnkw, Toast.LENGTH_LONG).show();
}
}
});
}else {
Toast.makeText(getActivity(), R.string.eReviewErrTxt, Toast.LENGTH_LONG).show();
}
I have tried to put push() into diffrent positions but still same. DB structure looks like this It should create DB structure like this on image
Edit: Database structure should look like this
enter code here
DB
└attr_reviews
└city1
└useruuid1
└comment: ""
└rating: x
└useruuid2
└....
└city2
└....
