Basically, I would like to know if it is possible to update all of the documents found in a collection in Firestore. I am able to get all the documents in a list like so:
<
In order to update all the documents in a collection first you have have to retrieve all of them in a List and then iterate that list and update them. Here is a sample code:-
for (int k = 0; k < list.size(); k++) {
firestore.collection("Events").document(list.get(k))
.update("Key", value).addOnSuccessListener(new OnSuccessListener()
{
@Override
public void onSuccess(Void aVoid) {
Log.i("Update", "Value Updated");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(MainActivity.this, "Error In Updating Details: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}