Skip to content Skip to sidebar Skip to footer

How To Retrieve Value In Recyclerview I Tried A Lot But It Retrieve A Null Value From Generated Id By Firebase After Push Data In Database In Android

How to retrieve value in RecyclerView I tried a lot but it retrieve a null value from generated id by Firebase after push data in database and if I don't using this method 'push' t

Solution 1:

You are getting the following warning:

W/ClassMapper:Nosetter/fieldfor-L9VWgoCymRWj9zbgK5H

Because you are using wrong getters for your fields. The correct getter for a field that looks like this:

privateString mMemberEmail;

Should be:

publicStringgetMMemberEmail() { //See the first capital Mreturn mMemberEmail;
}

The correct naming for the fields and getters inside a model should be:

publicclassTasks {
    privateString memberEmail;
    privateString taskName;
    privateString taskDsc;
    privateString taskDeadline;

    publicTasks() {}

    publicTasks(String memberEmail, String taskName, String taskDsc, String taskDeadline) {
        this.memberEmail = memberEmail;
        this.taskName = taskName;
        this.taskDsc = taskDsc;
        this.taskDeadline = taskDeadline;
    }

    publicStringgetMemberEmail() {return memberEmail;}

    publicStringgetTaskName() {return taskName;}

    publicStringgetTaskDsc() {return taskDsc;}

    publicStringgetTaskDeadline() {return taskDeadline;}
}

So remember, when the Firebase Realtime Database SDK deserializes objects coming from the database, is looking for fields that follow the principles of the JavaBeans and are named accordingly to Java Naming Conventions. So the corresponding getter for a field like memberEmail is getMemberEmail() and not getmemberEmail(). To make it work entirely, delete old data and add fresh one.

Post a Comment for "How To Retrieve Value In Recyclerview I Tried A Lot But It Retrieve A Null Value From Generated Id By Firebase After Push Data In Database In Android"