I am using the following class in my android project to upload data into its firebase backend.
public class IATFPojo {
public Double ecc, ecc2;
public boolean prenhes, ressinc;
public Long diasp, cl;
public String localiza, datacob;
public IATFPojo() {}
public IATFPojo(double ecc, boolean prenhes, boolean ressinc, long diasp, String localiza, String datacob, double ecc2, long cl){
this.ecc = ecc;
this.ecc2 = ecc2;
this.prenhes = prenhes;
this.ressinc = ressinc;
this.diasp = diasp;
this.cl = cl;
this.localiza = localiza;
this.datacob = datacob;
}
public Double getEcc() {
return ecc;
}
public Double getEcc2() {
return ecc2;
}
public boolean isPrenhes() {
return prenhes;
}
public boolean isRessinc() {
return ressinc;
}
public Long getDiasp() {
return diasp;
}
public Long getCl() {
return cl;
}
public String getLocaliza() {
return localiza;
}
public String getDatacob() {
return datacob;
}
}
And I am inserting it in firebase like this:
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference();
IATFPojo pojo = new IATFPojo(
//ecc, prenhes, ressinc, diasp, localiza, datacob, ecc2, cl
(map.get("IATF6")).length() > 0 ? Double.parseDouble(map.get("IATF6")) : 0,
Integer.parseInt(map.get("IATF20")) > 1,
Integer.parseInt(map.get("IATF5")) > 1,
Long.parseLong(map.get("IATF30")),
map.get("IATF23"),
map.get("IATF1"),
(map.get("IATF22")).length() > 0 ? Double.parseDouble(map.get("IATF22")) : 0,
Long.parseLong(map.get("IATF21"))
);
myRef.child(uid +"/MULTIPARA").child(map.get("IATF1")+"_"+map.get("SUI")).setValue(pojo);
It creates a node with the user id (uid) and another node with the reference (MULTIPARA), and then the child which contains the data using the format date_animal id. The problem is that the data is being stored like this in the firebase:
And as I understood the data should have the IATFPojo keys like this:
2016-11-11_ A 335
ecc: 2.75
ecc2: 3
prenhes: true
ressinc : false
diasp: 52
cl: -1
localiza: "16 IATF BV 5"
datacob: "2016-11-11"
Am I missing something in the configuration of the class, or in firebase ?
Cricket_007's comments lead me to the answer. I have created a new package in my android project to include all POJO classes to upload to firebase and then included the following line to my proguard rules:
-keepnames class newPackage.** { *; }
So now all my android POJOs are being uploaded to firebase with the correct field keys.
Thank you cricket_007.