title: Where to put AysncTask class in a ListActivity
body: <p>I have class which extends ListActivity and sets the adapter, and a adapter class which populates the view with data from a DB. I wanted to add a progress dialog programmicatlly in the List activity class as the views are been populated and wrap the time consuming tasks in asynch inner class. </p>
  
  <p>I am wondering where is the best place to implement the asynch task, i plan too incorporate the dialog progress in pre Execute and post Execute. </p>
  
  <p>Code form list activity class onCreate :</p>
  
  <pre><code>data = new diveDataBase(this);
  data.open();
  cursor = data.getCursorData();
  
  //check if data available
  if(cursor!=null &amp;&amp; cursor.getCount()&gt;0){
      // get customised array adoater list
      adapter = new ItemAdapter(this, cursor);
  
      this.setListAdapter(adapter);
      data.close();
  }
  </code></pre>
  
  <p>And the adapter class bind view method with the cursor object passed as a parameter:</p>
  
  <pre><code>String diveSite = c.getString(c.getColumnIndexOrThrow(diveDataBase.KEY_DIVESITE));
  String date = c.getString(c.getColumnIndexOrThrow(diveDataBase.KEY__DIVEDATE));
  String diveNumber= c.getString(c.getColumnIndexOrThrow(diveDataBase.KEY__DIVENUMBER));
  String diveImagePath = c.getString(c.getColumnIndex(diveDataBase.KEY_DIVEPICTURE));
  String rating = c.getString(c.getColumnIndexOrThrow(diveDataBase.KEY_DIVERATING));
  
  /**
   * Next set the dive site name
   */
  
  TextView title_text = (TextView) v.findViewById(R.id.tv_DiveSiteListView);
  if (title_text != null) {
         title_text.setText(diveSite);
  }
  //populate another textview and image view etc
  </code></pre>
  
  <p>Edit: My Code for aycnh class</p>
  
  <p>So I ended u wrapping the code for getting the DB cursor in the do-in-background and creation of adapter and setting it in the the post-execute, is this the best way as the DB at the moment is not large enough to test:</p>
  
  <pre><code>        @Override 
          protected Cursor doInBackground(Void... params) { 
  
  
  &gt;                       ViewListOfDives.data = new diveDataBase(ViewListOfDives.this);
  &gt;                       ViewListOfDives.data.open();
  &gt;                       // get cursor object holding all data, use a asynch inner class to load 
  &gt;                       cursor = data.getCursorData();
  &gt; 
  &gt;                       
  &gt;                                   return cursor;      
  }
  
  &gt; @Override         
  protected void onPostExecute(Cursor cursor) { 
                      if(pd.isShowing()){
  &gt;                       pd.dismiss();           }
  &gt;                       //check if data available
  &gt;                       if(cursor!=null &amp;&amp; cursor.getCount()&gt;0){
  &gt;                       // get customised array adoater list
  &gt;                       adapter = new ItemAdapter(ViewListOfDives.this, cursor);
  &gt;                       }else{
  &gt;                           
  &gt;                               //display o dives in data base message and finish this activity
  &gt;                               displayDialog();
  &gt;                           
  &gt;                       }
  &gt;                       ViewListOfDives.this.setListAdapter(adapter);
  &gt;                       ViewListOfDives.data.close();           super.onPostExecute(cursor);        }
  &gt; 
  &gt; 
  &gt; 
  &gt; 
  </code></pre>