0
I am 8 days trying to get from firebase the records I put there. However, I can never bring them properly.
--- Android for Firebase
private void initPreencheLista() {
listCelula.clear();
novaRef = databaseReference.child( "Celulas" );
novaRef.addValueEventListener( new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Celula c = new Celula();
for(DataSnapshot objSnapshot:dataSnapshot.getChildren()){
c = objSnapshot.getValue(Celula.class);
cels.add( c.getCelula() );
}
arrayAdapterCelula = new ArrayAdapter<String>(CelulasActivity.this,android.R.layout.simple_list_item_1, cels );
celulaList.setAdapter( arrayAdapterCelula );
}
I tried so many ways to do that I even used
for(DataSnapshot objSnapshot:dataSnapshot.getChildren()){
String a = objSnapshot.child( "Celula" ).getValue(String.class);
cels.add( a );
I just can’t give up. I’m in the fight, if anyone can help me I’ll be grateful.
In the first way the objSnapshot comes loaded with all the object I called. Error: com.google.firebase.database.Databaseexception: Can’t Convert Object of type java.lang.String to type cellulae.Cellula.
I did so because I only need one for. But it was a mistake.
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
 for(DataSnapshot objSnapshot:dataSnapshot.getChildren()){
 Celula c = objSnapshot.getValue(Celula.class);
 String celula = c.getCelula();
 cels.add( celula );
com.google.firebase.database.Databaseexception: Can’t Convert Object of type java.lang.String to type cellulae. Cellula– user65509
private void initPreencheList() { listCelula.clear(); novaRef = databaseReference.Child( "Cells" );
– user65509
Dude! I did it again as Iassuli made two gift for and it worked. I can’t believe it. Thank you. They should put that in the Firebase documentation. I find incomplete.
– user65509