The problem in your code lies in the fact that you have in your CustomListAdapter
class a field named ItemName
but you are using a getter named getItemName()
, which is not correct since Firebase is looking in the database for a field named itemName
and not ItemName
. See the lowercase i
letter vs. capital letter I
?
There are two ways in which you can solve this problem. The first one would be to change your model class by renaming the fields according to the Java Naming Conventions. So you model class should look like this:
public class CustomListAdapter {
private String itemName, quantity, serialNo, supplierName, supplierEmail, supplierPhone;
public CustomListAdapter() {}
public CustomListAdapter(String itemName, String quantity, String serialNo, String supplierName, String supplierEmail, String supplierPhone) {
this.itemName = itemName;
this.quantity = quantity;
this.serialNo = serialNo;
this.supplierName = supplierName;
this.supplierEmail = supplierEmail;
this.supplierPhone = supplierPhone;
}
public String getItemName() { return itemName; }
public String getQuantity() { return quantity; }
public String getSerialNo() { return serialNo; }
public String getSupplierName() { return supplierName; }
public String getSupplierEmail() { return supplierEmail; }
public String getSupplierPhone() { return supplierPhone; }
}
See in this example, there are private
fields and public getters. There is also a simpler solution, to set the value directly on public fields like this:
public class CustomListAdapter {
public String itemName, quantity, serialNo, supplierName, supplierEmail, supplierPhone;
}
Now just remove the current data and add it again using the correct names. This solution will work only if you are in testing phase.
There is also the second approach, which is to use annotations
. So if you prefer to use private fields and public getters, you should use the PropertyName annotation only in front of the getter. So your CustomListAdapter
class should look like this:
public class CustomListAdapter {
private String ItemName;
private String Quantity;
private String SerialNo;
private String SupplierName;
private String SupplierEmail;
private String SupplierPhone;
public CustomListAdapter() {}
public CustomListAdapter(String itemName, String quantity, String serialNo, String supplierName, String supplierEmail, String supplierPhone) {
ItemName = itemName;
Quantity = quantity;
SerialNo = serialNo;
SupplierName = supplierName;
SupplierEmail = supplierEmail;
SupplierPhone = supplierPhone;
}
@PropertyName("ItemName")
public String getItemName() { return ItemName; }
@PropertyName("Quantity")
public String getQuantity() { return Quantity; }
@PropertyName("SerialNo")
public String getSerialNo() { return SerialNo; }
@PropertyName("SupplierName")
public String getSupplierName() { return SupplierName; }
@PropertyName("SupplierEmail")
public String getSupplierEmail() { return SupplierEmail; }
@PropertyName("SupplierPhone")
public String getSupplierPhone() { return SupplierPhone; }
}