I am studying in France and I have trouble finding French tutorials to solve my problem. I am therefore obliged to ask my question, hoping to have a satisfactory solution.
My problem is that I have trouble reading my data on firebase and I have spent three days on it.
I have a structure like this:
I had started to code something, I was able to recover the key but I could not recuperate these values "nom" "argent" etc .
private Firebase mRef ;
mRef = new Firebase("https://authent-50e6b.firebaseio.com/users");
mRef.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String cle = dataSnapshot.getKey();
Toast.makeText(ListeActivity.this,"la cle est : "+cle ,Toast.LENGTH_SHORT).show();
An alternative to John's is to use DataSnapshot.child() to get to each property:
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String cle = dataSnapshot.getKey();
String nom = dataSnapshot.child("nom").getValue(String.class);
Toast.makeText(ListeActivity.this,"la cle est : "+cle+" nom est : "+nom ,Toast.LENGTH_SHORT).show();
You would need something like following (assuming you have User pojo whose fields map to those in firebase db)
User user = dataSnapshot.getValue(User.class);
String nom = user.getNom();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With