如何使android中的这种结构发送到firebase firestore?

如何使android中的这种结构发送到firebase firestore?,android,firebase,google-cloud-firestore,Android,Firebase,Google Cloud Firestore,我用的是这个结构 public class NewVendor { public String title; public Map<String,String> array; public NewVendor(String title, Map<String, String> array) { this.title = title; this.array = array; } } Map<Str

我用的是这个结构

public class NewVendor
{
    public String title;


    public Map<String,String> array;

    public NewVendor(String title, Map<String, String> array) {
        this.title = title;
        this.array = array;
    }
}

Map<String,String> list = new HashMap<>();
        list.put("Vendor Name",newVendorName);
        list.put("Vendor Address",newVendorAddress);

        NewVendor newVendor = new NewVendor(newVendorName,list);

        db.collection("Bills").document(firebaseUser.getUid()).set(newVendor)
                .addOnSuccessListener(new OnSuccessListener<Void>() {
                    @Override
                    public void onSuccess(Void aVoid)
                    {
                        Toast.makeText(AddNewBillActivity.this, "Success", Toast.LENGTH_SHORT).show();
                    }
                }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(AddNewBillActivity.this, "Failure", Toast.LENGTH_SHORT).show();
            }
公共类NewVendor
{
公共字符串标题;
公共地图阵列;
public NewVendor(字符串标题、映射数组){
this.title=标题;
this.array=数组;
}
}
映射列表=新的HashMap();
list.put(“供应商名称”,newVendorName);
列表。放置(“供应商地址”,新供应商地址);
NewVendor NewVendor=新的NewVendor(NewVendor名称,列表);
db.collection(“Bills”).document(firebaseUser.getUid()).set(newVendor)
.addOnSuccessListener(新的OnSuccessListener(){
@凌驾
成功时公开作废(作废避免)
{
Toast.makeText(addnewbilactivity.this,“Success”,Toast.LENGTH_SHORT.show();
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
Toast.makeText(addnewbilactivity.this,“Failure”,Toast.LENGTH_SHORT.show();
}

但它不起作用。它正在覆盖上次保存的数据,但我想添加最新的对象。Firestore中不允许使用ArrayList。

您正在查找更新现有文档,因此应调用
更新
。这要求您指定要更新的文档字段,在您的情况下为
newVendorNamee> :

Map<String,Object> updates = new HashMap<>();
updates.put(newVendorName, newVendor);
        db.collection("Bills").document(firebaseUser.getUid()).update(updates)...
Map updates=newhashmap();
updates.put(newVendorName,newVendorName);
db.collection(“Bills”).document(firebaseUser.getUid()).updates(更新)。。。
有关这方面的更多信息,请阅读