title: return an object Android
body: <p>I want to return an object with some things in them.</p>
  
  <p>Here is the declaration;</p>
  
  <pre><code>Object user_det = get_user_det();
  </code></pre>
  
  <p>Here is the function code:</p>
  
  <pre><code>        private Object get_user_det() {
          Firebase f_user = new Firebase("https://myapp.firebaseio.com/User/");
          f_user.addListenerForSingleValueEvent(new ValueEventListener(){
              @Override
              public void onDataChange(DataSnapshot snap_user) {
                  // TODO Auto-generated method stub
                  Iterable&lt;DataSnapshot&gt; rs = snap_user.getChildren();
                  Iterator&lt;DataSnapshot&gt; irs = rs.iterator();
                  long allNum2 = snap_user.getChildrenCount();
                  int maxNum2 = (int)allNum2;
                  int count_user = 1;
                  while(irs.hasNext())
                  {
                      if(count_user &lt;= maxNum2)
                      {
                          Firebase user_data = new Firebase("https://myapp.firebaseio.com/"); 
                          AuthData authData = user_data.getAuth();
                          Map&lt;String, Object&gt; nPost = (Map&lt;String, Object&gt;) irs.next().getValue();
  
                          String db_email = nPost.get("email_addr").toString();
  
                          if (authData != null) {
                              String usr_email = authData.getProviderData().get("email").toString();
                              if(usr_email.equals(db_email))
                              {
                        //NB: I WANT TO ADD THE FOLLOWING INTO THE OBJECT
                                  String disp_name = nPost.get("disp_name").toString();
                                  String real_name = nPost.get("real_name").toString();
                              }
  
                          } else {
                              System.out.println("Failed");
                          }
                      }
                      count_user++;
                  }                       
              }
              @Override
              public void onCancelled(FirebaseError arg0) {
                  // TODO Auto-generated method stub
  
              }
      }); 
      return null; //NB: I NEED TO RETURN THE OBJECT HERE.
  }
  </code></pre>
  
  <p>I want to return the string disp_name and real_name but they are inside the addListenerForSingleValueEvent, so how do I get them out and return it to the function.</p>
  
  <blockquote>
    <p>I have wrote "NB" in the code where I need help with.</p>
  </blockquote>
  
  <p>Thanks for your time.</p>