Can not convert object of type java.lang.String to type geoapp.cursoandroid.com.geoapp.model.Project

-1

I have a Firebase data recovery method:

public void recuperaProjetos(){
    DatabaseReference projetosRef = firebaseRef
            .child("projeto")
            .child(idUsuario);

    projetosRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            projetos.clear();
            for(DataSnapshot ds: dataSnapshot.getChildren()){
                projetos.add(ds.getValue(Projeto.class));
            }
            adapterProjetos.notifyDataSetChanged();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

If I leave this part like this:

DatabaseReference projetosRef = firebaseRef
            .child("projeto")

I have the expected return, now if I want to select the projects according to the id, like this:

DatabaseReference projetosRef = firebaseRef
            .child("projeto")
            .child(idUsuario);

It gives the error: Can not convert object of type java.lang.String to type geoapp.cursoandroid.com.geoapp.model.Project in line:

 projetos.add(ds.getValue(Projeto.class));

Where am I going wrong?

    
asked by anonymous 04.01.2019 / 15:19

0 answers