title: Return data from AsyncTask Android
body: <p>I tried to refer similar question on SO, but didn't got any help.</p>
  
  <p>In my android app,  I'm planning to implement Recent Quote the user has visited i.e. similar to recently visited pages on web.      </p>
  
  <p>Following are the steps I'm following:</p>
  
  <p>1.) Whenever user opens any company view, <strong>fetch the company symbols from database</strong></p>
  
  <p>2.) Then <strong>store the current symbol</strong> along with dateTime in database.</p>
  
  <p>3.) For all symbols fetched from database, <strong>Fetch their <code>current value</code> and <code>%Change</code></strong> and display <strong>Company name, current value and %Change</strong> in a list.</p>
  
  <p>The problem arises in the <code>ASyncTask</code> class as <code>postExecute</code> method doesn't allow it's return type to be any other than <code>void</code>.</p>
  
  <p><strong>Am I doing anything wrong?</strong></p>
  
  <p><em>Any help will be life saver !!!</em></p>
  
  <pre><code>String[] rsym,rcmp,rchg;
  rdbM = new RecentDBManager(CompanyView.this);
  try {
  Calendar date1 = Calendar.getInstance();
  SimpleDateFormat dateformatter = new SimpleDateFormat(
                              "dd/MM/yyyy HH:mm:ss");
  
  String currentdate = dateformatter.format(date1.getTime());
  
  rdbM.openDB();
  
  //STEP 1
  rsym = rdbM.getRecent_sym();
  
  //STEP 2                
  rdbM.setData(currentsymbol, currentdate);
  
  rdbM.closeDB();
  
  } catch (Exception e) {
  throw new Error(" *** ERROR in DB Access *** "+ e.toString());
  }
  
   //STEP 3
          for(int i=0;i&lt;rsym.length;i++)
          {
              DownloadRecentQuote quotetask = new DownloadRecentQuote();
              recentquotetask
              .execute(new String[] { "http://abc.com/stockquote.aspx?id="
                          + rsym[i] });
  
   //CURRENT VALUE and %CHANGE which should be returned from ASyncTask class
  
              rcmp[i]=valuearr[0];
              rchg[i]=valuearr[1];
              }
  
              list1 = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              HashMap&lt;String, String&gt; addList1;
  
              for (int i = 0; i &lt; limit; i++) 
              {
                  addList1 = new HashMap&lt;String, String&gt;();
                  addList1.put(RecentSym_COLUMN, rsym[i]);
                  addList1.put(RecentCMP_COLUMN, rcmp[i]);
                  addList1.put(RecentChg_COLUMN, rchg[i]);
  
                  list1.add(addList1);
  
                  RecentAdapter adapter1 = new RecentAdapter(
                      CompanyView.this, CompanyView.this, list1);
                  listrecent.setAdapter(adapter1);
              }
  
  
  private class DownloadRecentQuote extends AsyncTask&lt;String, Void, String&gt; {
      /* Fetching data for RecentQuote information */
      @Override
      protected String doInBackground(String... urls) {
          String response = "";
          for (String url : urls) {
              DefaultHttpClient client = new DefaultHttpClient();
              HttpGet httpGet = new HttpGet(url);
              try {
                  HttpResponse execute = client.execute(httpGet);
                  InputStream content = execute.getEntity().getContent();
  
                  BufferedReader buffer = new BufferedReader(
                          new InputStreamReader(content));
                  String s = "";
                  while ((s = buffer.readLine()) != null) {
                      response += s;
                  }
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
          return response;
      }
  
      @Override
      protected void onPostExecute(String result) {
  
          arr1 = result.split("@");
  
          if (arr1[0].length() != 0) {
  
              if (arr1[0].equals("1")) {
  
                  arr = arr1[1].split(";");
  
              //RETURN 2 STRINGS
                              String valuearr[];
                  valuearr[0] = arr[3];
                  valuearr[1] = arr[6].concat("%");
                  //return valuearr;
              }
          }
      }
  </code></pre>