I have a column name viewed_by on Firebase server
Test
|
|--viewed_by: 30
On the app I have a POJO class which has the member viewed_by
Test.class has member
private int viewed_by;
In onDataChange function when I receive the data, I get the Test object using the getValue function
Test t = dataSnapshot.getValue(Test.class);
But I get the value as 0 instead of 30.
If I change the field name from viewed_by to viewedBy (both on server and POJO class), I get the expected value (30)
Is it a parsing issue in getValue function? Or the field name are not supposed to have underscores in the name?
Jus figured it out, had to change the function names as well from ViewedBy to Viewed_By for it to work with viewed_by field
/**
*
* @return
* The viewed_by
*/
public int getViewed_By() {
return viewed_by;
}
/**
*
* @param viewed_by
* The viewed_by
*/
public void setViewed_By(int viewed_by) {
this.viewed_by = viewed_by;
}