Problem retrieving values from firebase to list

0

I am making a list, and in this list I pull the following information id, idPost, description, userName and photoUser.

But to popular (add) data to this list I'm using the following code snippet inside an activity:

        itensSalvosRef = ConfiguracaoFirebase.getFirebase().child("itens-salvos").child(idUsuarioLogado);        

        @Override
        protected void onStart() {
            super.onStart();
            listarItensSalvos();
        }    

        private void listarItensSalvos() {

            valueEventListener = itensSalvosRef.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {

                    listaItemSalvo.clear();

                    for (DataSnapshot ds : dataSnapshot.getChildren()) {

                        listaItemSalvo.add(ds.getValue(ItemSalvo.class));

                    }

                    Collections.reverse(listaItemSalvo);
                    itensSalvosAdapter.notifyDataSetChanged();
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

        }

Firebase structure:

Theideaisthatitretrievesallvalues,butitonlyretrievestheuserName,asshowninthepicturebelow:

What am I doing wrong to the popular (add values) to this list?

    
asked by anonymous 15.11.2018 / 12:47

1 answer

1

The names of the properties of your class ListItemSalvo are totally different from your database firebase, only the username field is correct, so only it is coming filled ...

Your class ListException is like this:

descricao
fotoPostagem
id
nomeUsuario

But the right thing, I believe, is that it should be

feedDescricao
feedFoto
feedId
nomeUsuario

Always try to create your classes by giving names to the properties that are the same as the bank fields, that is, always try to mirror the bank in your class, this facilitates understanding and also makes everything more practical.

    
15.11.2018 / 13:11