2021年2月5日星期五

how to specific one value to increment in firebase real-time database?

Problem is when I use this code for increment specific value in database it increment all values

 databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {                                  @Override                                  public void onDataChange(@NonNull DataSnapshot snapshot) {                                        for (DataSnapshot dataSnapshot: snapshot.getChildren()) {                                                id = dataSnapshot.getKey();                                              Long count = snapshot.child(id).child("count").getValue(Long.class);                                                databaseReference.child(id).child("count").setValue(count + 1);                                              Toast.makeText(Raees_At7ad.this, "تم التصويت", Toast.LENGTH_SHORT).show();                                                                                   }                                  }  

I have recyclerView has some items I want increment specific count when click on one item, but it increment all count in database

firebase

https://stackoverflow.com/questions/66072589/how-to-specific-one-value-to-increment-in-firebase-real-time-database February 06, 2021 at 09:05AM

没有评论:

发表评论