title: Convert Arraylist to Array, data of Arraylist is of custom class type
body: <p>I have retrieved data from database and added to Arraylist using a class called AddDetails. In AddDetails class I am assigning all values. Then I have sent that ArrayList to activity class where I need to display that data in ListView. Now while copying data from ArrayList to Array I am getting error like class not found or while displaying on list view it is just showing some garbage value.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code> private class SearchTask extends AsyncTask&lt;Void, Void, Void&gt;{
  @Override
     protected Void doInBackground(Void... arg0) {
      // TODO Auto-generated method stub
  
       DatabaseHandler db = new DatabaseHandler();          
  
       String Place = etSearch.getText().toString();
       AddDetails details = new AddDetails(Place);
       alSearchResult = db.searchResultByPlace(details);
       arrStr = new String[alSearchResult.size()];
  
       try
       {
      arrStr = (String[]) alSearchResult.toArray();               
         ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(SearchActivity.this,           android.R.layout.simple_list_item_multiple_choice, arrStr);
  
      lsSearchResult.setAdapter(adapter);
        }
  
        catch(Exception e)
        {
          Log.e("Error:" + e.toString());
        }
  
  
      return null;
  }
  
  
  
  
  
   protected ArrayList&lt;AddDetails&gt; searchResultByPlace(AddDetails details)
  {
  ArrayList&lt;AddDetails&gt; alSearchData = null;
  try
  {
       String place = details.getPlace();
  
        Cursor c = mDataBase.rawQuery("SELECT * FROM " + ESTATE_DETAILS + " WHERE " +           strSearchType + " =  " + "'" + place + "'", null);
      c.moveToFirst();
      if(c.getCount() &gt; 0)
      {
       alSearchData = new ArrayList&lt;AddDetails&gt;();
      if (c.moveToFirst()) 
      {
      do {
          details = new AddDetails();  
                      details.setID(Integer.parseInt(c.getString(0)));
              details.setPlace(c.getString(1));                        
                      details.setArea(c.getString(2));
              details.setType(c.getString(3));
              details.setPhoneNumber(c.getString(4));                                                                                                                                 
  
           // Adding contact to list
          alSearchData.add(details);
      } while (c.moveToNext());
     }
  
  }
  
  c.close();
  }
  catch(SQLException e)
  {
  Log.e("Error:", e.toString());
  }
  
  return alSearchData;
  </code></pre>
  
  <p>}</p>