Skip to content Skip to sidebar Skip to footer

Firebase Read Getter Setter

I was trying to get some data from my Firebase realtime-database as followed generally, but couldn't figure out where in the code the problem was haunting me.The following Toast st

Solution 1:

The problem lies in the fact that you have an incorrect getter for bmdc field in your model class. The correct getter should be getBmdc() and not getbmdc() as it is in your code now. See the capital letter B versus lower case letter b? The correct model class should look like this:

public class FindDoctors {
    private String bmdc, name;

    public FindDoctors() {}

    public FindDoctors(String bmdc, String name) {
        this.bmdc = bmdc;
        this.name = name;
    }

    public String getBmdc() { return bmdc; }

    public String getName() { return name; }
}

The setters are not required, are always optional because if there is no setter for a JSON property, the Firebase client will set the value directly onto the field. But if you wish to use setters, the correct setter for your field is:

public void setBmdc(String bmdc) {
    this.bmdc = bmdc;
}

Post a Comment for "Firebase Read Getter Setter"