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 notgetbmdc()
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:
publicclassFindDoctors {
privateString bmdc, name;
publicFindDoctors() {}
publicFindDoctors(String bmdc, String name) {
this.bmdc = bmdc;
this.name = name;
}
publicStringgetBmdc() { return bmdc; }
publicStringgetName() { 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:
publicvoidsetBmdc(String bmdc) {
this.bmdc = bmdc;
}
Post a Comment for "Firebase Read Getter Setter"