Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

for loop in firebase snapshot in java

FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
myRef.addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
    for(DataSnapshot item_snapshot:dataSnapshot.getChildren()) {

      Log.d("item id ",item_snapshot.child("item_id").getValue().toString());
      Log.d("item desc",item_snapshot.child("item_desc").getValue().toString());
     }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #loop #firebase #snapshot #java
ADD COMMENT
Topic
Name
8+7 =