'How can I delete specific data from each user in firebase
Solution 1:[1]
There is no magic here. You'll have to read all users, loop over them, and then delete their points one-by-one, or through a multi-path update.
Something like:
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("UsersExample");
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Map<String, Object> updates = new HashMap<>();
for (DataSnapshot userSnapshot: dataSnapshot.getChildren()) {
updates.put(userSnapshot.getKey()+"/point", null); // Setting to null will delete that node
}
userRef.updateChildren(updates);
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Frank van Puffelen |