Reputation: 27
I'm trying to add users who applying for the job and I wanna storage this users in same field but my code deletes previous user so how can I I can add it without deleting previous user here is my code
String email=user.getEmail();
HashMap<String,Object> basvurubilgileri=new HashMap<>();
basvurubilgileri.put("İlana Başvuran Kişiler",email);
firestore.collection("İlanlar").document(ilanbaslıgı).update(basvurubilgileri).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
Toast.makeText(Basvurma.this, "Başvurunuz Başarılı Bir Şekilde Yapılmıştır", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(Basvurma.this,Secimekrani.class);
startActivity(intent);
finish();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Basvurma.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
Upvotes: 0
Views: 54
Reputation: 599081
It sounds like you want İlana Başvuran Kişiler
to be an array field. To add a value to an array field, you can use array-union
basvurubilgileri.put("İlana Başvuran Kişiler",FieldValue.arrayUnion(email));
The rest of your could stays the same with this.
Upvotes: 2