title: Android call notifyDataSetChanged from AsyncTask
body: <p>I've a custom ListAdapter that fetches data from internet in an AsyncTask.</p>
  
  <p>The data is added perfectly to the list, but when I try to do operations the application crashes...</p>
  
  <p>I'm sure this is because I'm calling notifyDataSetChanged(); at the wrong time (i.e. before the AsyncTask ends).</p>
  
  <p>What I've got now:</p>
  
  <pre><code>public class MyListAdapter extends BaseAdapter {
      private ArrayList&lt;String&gt; mStrings = new ArrayList&lt;String&gt;();
  
      public MyListAdapter() {
          new RetreiveStringsTask().execute(internet_url);
          //here I call the notify function ****************
          this.notifyDataSetChanged();
      }
  
      class RetreiveStringsTask extends AsyncTask&lt;String, Void, ArrayList&lt;String&gt;&gt; {
          private Exception exception;
  
          @Override
          protected ArrayList&lt;String&gt; doInBackground(String... urls) {
              try {
                  URL url= new URL(urls[0]);
                  //return arraylist
                  return getStringsFromInternet(url);;
              } catch (Exception e) {
                  this.exception = e;
                  Log.e("AsyncTask", exception.toString());
                  return null;
              }
          }
  
          @Override
          protected void onPostExecute(ArrayList&lt;String&gt; stringsArray) {
              //add the tours from internet to the array
              if(stringsArray != null) {
                  mStrings.addAll(toursArray);
              }
          }
      }
  }
  </code></pre>
  
  <p>My question is: can I call notifyDataSetChanged() from the onPostExecute function in the AsyncTask or at any other time when the AsyncTask has fetched the data?</p>