Is it possible to cancel AsyncTask that has one line command in doInBackground that performs a very long operation,like
@Override
protected Boolean doInBackground(String... filename) {
fetchfile(filename[0]);
// ...
// ...
return ...;
}
You can
AsyncTask.cancel()to cancel. You can cancel it inside thefetchFilemethod at an appropriate place where you feel it will not introduce inconsistencies in your data or at a place where its easier to rollback.