title: How can i save data retrieved from firebase into arraylist
body: <h2>this is the code i am using but the data cannot be accessed out the datasnapshot and the data is been successfully retrieved which i can view in my logcat ,but it just does not get added in Arraylist  ##```try {</h2>
  <pre><code>        mbase = FirebaseDatabase.getInstance().getReference(&quot;/information/&quot; + y2+&quot;/&quot;+c2+&quot;/&quot;+s2+&quot;/&quot;);
          mbase.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  for (DataSnapshot ds : snapshot.getChildren()) {
                      String key = ds.getKey();
                      mySubject.add(key);
                      //Log.i(&quot;SubjectNo&quot;, key);
                  }
              }
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
              }
          });
      }catch (Exception e){
          e.printStackTrace();```
  </code></pre>