Rectangle 27 0

android No setterfield for warning Firebase Database Retrieve Data Populate Listview?


I am still having problems adding the collected data to the listview via the adapter. What else am I missing? I have adjusted the code to what you suggested. Check the update.

In retrieveData(), you should be using a ChildEventListener, not a ValueEventListener. You are adding Node objects as children of node/$uid with the keys generated by push(). The ValueEventListener is returning a Map<String,Object> containing all of the Nodes. That is shown in the logcat output you posted. You can use the onChildAdded() callback of ChildEventListener to get each Node as it is created and then add it to your adapter.

Use the Firebase console to examine the value and nodes/$uid to confirm that it has children that are Nodes. Is there possibly some old data leftover from previous runs? If so, you can use the console to delete the extraneous values.

What behavior are you seeing now? Not seeing the error message any longer? Do you have a log statement in onChildAdded() to confirm that it is firing?

says it's caused by the line with the code for NodeObject nodeObject = datasnapshot.getValue(NodeObject.class);

Note
Rectangle 27 0

android No setterfield for warning Firebase Database Retrieve Data Populate Listview?


public class NodeObject {
    public String staticAddress;
    public String lat;
    public String lon;

    public NodeObject(){
        //needed for firebase
    }

    public NodeObject(String address, String lat, String lon){
        this.staticAddress = address;
        this.lat = lat;
        this.lon = lon;
    }
}

Following the examples in the Firebase documentation, this seems like the better way to model the Java class:

I took your advice, and redid the object. Thanks for the heads up!

The warning is because the casing mismatches between your field and you setter.

long is reserved word, it is a primitive type, and Long for the wrapper class.

Note
Rectangle 27 0

android No setterfield for warning Firebase Database Retrieve Data Populate Listview?


As a side note, know that your naming is typically against convention. Generally, variables prefixed by m are private member variables, accessed & mutated by public methods (like yours).

For your case, you might just be able to change your methods to be getMLat() and setMLat(). Although I'd suggest changing up your conventions a bit in general.

I had the same issue just now & the answer was pretty frustrating.

I think that the issue is with your naming convention. For example, it looks like you named a variable mLat, and then your accessors/mutators are getmLat() and setmLat(). I think when Firebase is doing the deserialization, they rely on certain naming. For example, if you have a member variable named lat, you will need to have getLat() and setLat().

Note