title: How to return ArrayList from AsyncTask to another class?
body: <p>i want to get Ftp folders list from server using AsyncTask and return folders names ArrayList to main class and update spinner adapter.</p>
  
  <p>In main class i got spinner with adapter</p>
  
  <pre><code>//the array i want to update in AsyncTask
  static ArrayList&lt;String&gt; directoriesTeacher = new ArrayList&lt;String&gt;();
  
  //The adapter
  createfile_spinTeacher = (Spinner) findViewById(R.id.createfile_spinTeacher);   
  final ArrayAdapter&lt;String&gt; dataAdapterTeacher = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item,directoriesTeacher);
  dataAdapterTeacher.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  createfile_spinTeacher.setAdapter(dataAdapterTeacher);
  </code></pre>
  
  <p>An in AsyncTask:</p>
  
  <pre><code>    package com.nedoGarazas.learnanylanguage;
  
      import java.util.ArrayList;
  
      import org.apache.commons.net.ftp.FTP;
      import org.apache.commons.net.ftp.FTPClient;
      import org.apache.commons.net.ftp.FTPFile;
      import org.apache.commons.net.ftp.FTPReply;
  
      import android.os.AsyncTask;
      import android.util.Log;
  
      public class FtpTeacher extends AsyncTask&lt;ArrayList&lt;String&gt;, Void, ArrayList&lt;String&gt;&gt; {
      private static final String TAG = "MyFTPClient";
      public FTPClient mFTPClient = null; 
       ArrayList&lt;String&gt; ftpTeacher = new ArrayList&lt;String&gt;();
      @Override
      protected ArrayList&lt;String&gt; doInBackground(ArrayList&lt;String&gt;... params) {
          {                       
              try {
                  mFTPClient = new FTPClient();
           // connecting to the host
                  mFTPClient.connect("host.ftp.com", 21);
  
            // now check the reply code, if positive mean connection success
                  if     (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
        // login using username &amp; password
                      boolean status = mFTPClient.login("admin", "admin");
                      if(status == true){
  
                              try {
                                  FTPFile[] ftpFiles = mFTPClient.listFiles("/Wordsftp/");
                                  int length = ftpFiles.length;
  
                                  for (int i = 0; i &lt; length; i++) {
                                      String name = ftpFiles[i].getName();
                                      boolean isDirectory = ftpFiles[i].isDirectory();
  
                                      if (isDirectory) {
  //adding to arraylist
                                          ftpTeacher.add(name);
                                          Log.i(TAG, "Yra : " + name);
                                      }
                                      else {
                                          Log.i(TAG, "Directory : " + name);
  
                                  }
                               }
                              } catch(Exception e) {
                              e.printStackTrace();
                          }
  
  
                      mFTPClient.setFileType(FTP.ASCII_FILE_TYPE);
                      mFTPClient.enterLocalPassiveMode();
  
  
  }
                  }
  } catch(Exception e) {
  Log.d(TAG, "Error: could not connect to host ");
  }
  return ftpTeacher;
  } 
              }
  
      protected ArrayList&lt;String&gt;[] onPostExecute(ArrayList&lt;String&gt;... result) {
          ////How to return?
  
      }
  
      }
  </code></pre>
  
  <p>So how should i replace arraylist in AsyncTask with ArrayList in main class and update spinner updater dinamicly?</p>