I have the following database node:
"ButtonState" : {
"payEnabled" : 0,
"requestEnabled" : 1
},
When a driver accepts a ride request from the rider,the value of "payEnabled = 1". I am trying to get the value of payEnabled after the driver accepts the request, but it errors out and I get this:
java.lang.NumberFormatException: For input string: "{payEnabled=0, requestEnabled=1}"
The code I am using to get the data is:
rootRef = rootRef.child("ButtonState");
rootRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
int payEnabled = Integer.valueOf(dataSnapshot.getValue().toString());
Log.e(TAG, "payEnabled = " + payEnabled);
if (payEnabled == 1) {
pulseAnimation();
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
What am I doing wrong, and how can I just get the value of "payEnabled"?