Search code examples
javaandroidfirebasefirebase-realtime-databasefirebaseui

Error when showing to FirebaseRecyclerAdapter from firebase database


I'm trying to show data from my Firebase database to RecylerView and I'm following this tutorial http://www.programmingviral.com/firebase-recyclerview-tutorial/

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.biodatalist_layout);
        ButterKnife.bind(this);

        recyclerView = findViewById(R.id.rec);

        LinearLayoutManager horizontalLayoutManagaer=new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false);
        recyclerView.setLayoutManager(horizontalLayoutManagaer);

        mdatabase = FirebaseDatabase.getInstance().getReference().child("Biodata");
        mdatabase.keepSynced(true);

        FirebaseRecyclerAdapter<BiodataModel, BiodataAdapter> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<BiodataModel, BiodataAdapter>(
                        BiodataModel.class,
                        R.layout.biodata_list_row,
                        BiodataAdapter.class,
                        mdatabase
                )
                {
                    @Override
                    protected void populateViewHolder(final BiodataAdapter viewHolder,final BiodataModel model,
                                                      int position) {
                        viewHolder.setEmailtext(model.getEmail());
                        viewHolder.setFullnametext(model.getFullname());

                    }

                };

        recyclerView.setAdapter(firebaseRecyclerAdapter);
    }

and my BiodataModel

public class BiodataModel {

    public String Fullname,Email,NoTelp,Alamat;

    public BiodataModel() {

    }

    public String getFullname() {
        return Fullname;
    }

    public String getEmail() {
        return Email;
    }

    public String getNoTelp() {
        return NoTelp;
    }

    public String getAlamat() {
        return Alamat;
    }

    public void setFullname(String Fullname) {
        this.Fullname = Fullname;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }

    public void setNoTelp(String NoTelp) {
        this.NoTelp = NoTelp;
    }

    public void setAlamat(String Alamat) {
        this.Alamat = Alamat;
    }
}

when i run this activity . I get this error

com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: alamat

my structure

enter image description here

How can i solve this ?


Solution

  • In your database, you have property: alamat with lowercase. But in the model class, you have the field Alamat with uppercase, both should be the same.

    Change the field in the model class:

    public String alamat;
    
    public String getAlamat() {
        return alamat;
    }
    
    public void setAlamat(String alamat) {
        this.alamat = alamat;
    }