title: Android create contact from class extending AsyncTask
body: <p>I use code from developers.android.com to create a contact</p>
  
  <pre><code>ArrayList&lt;ContentProviderOperation&gt; ops =
        new ArrayList&lt;ContentProviderOperation&gt;();
  
   int rawContactInsertIndex = ops.size();
   ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
        .withValue(RawContacts.ACCOUNT_TYPE, accountType)
        .withValue(RawContacts.ACCOUNT_NAME, accountName)
        .build());
  
   ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
        .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
        .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
        .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan")
        .build());
  
   getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
  </code></pre>
  
  <p>It works well when done from Activity, but I want to do it from a class, which extends AsyncTask. I did some research and ended up with conclusion, I need to pass somehow the context (because simple getActivity() won't work), so I can          context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
  but unfortunately no idea how to do it in my case</p>