According to the documentation, we can not add or remove from an array in firestore, I have read a couple of methods like Alex_Answer, another answer, also after reading a couple of answers I came to the conclusion instead of reading the entire array i save the array locally when i have to change something in that array and i update the locally saved array and use Update method to in firestore too
But I don't know if my approach of updating the entire array to change one field in Custom object.
My schema is like this image. Further, groups will have students array. so instead of removing the whole array I use the following code:
db.collection("teachers").document("user").update("myGroups", groups_arrayList).
addOnCompleteListener(new OnCompleteListener<Void>() {
//done
}