title: Do something if AsyncTask is cancelled?
body: <p>I'm using AsyncTask to populate SQLite database. I'm downloading data from a certain webpage and putting it in SQLite tables. The thing is, I want to either download 100% of the data or none. So in case the AsyncTask is for some reason interrupted, I want to delete all the data that has been downloaded so far.</p>
  
  <p>This is how I tried to do it:</p>
  
  <pre><code>@Override
  protected void onCancelled() {
      super.onCancelled();
      dbHandler.deleteFromDatabase(razred);
      Log.i("TAG", "AsyncTask cancelled");
  }
  </code></pre>
  
  <p>I thought that "onCancelled" will execute if AsyncTask is interrupted in any way but it doesn't. What could I do to erase data that was made with AsyncTask in case it is cancelled in any way? (ex. activity paused, activity destroyed, internet connection interrupted etc.)</p>