title: Application crashes onResume in ICS while working perfect on Gingerbread
body: <p>My main Activity (say A) raises intent to fetch a ContactID from ContactsContract through </p>
  
  <pre><code>startActivityForResult(new Intent(Intent.ACTION_PICK, contactsContract.Contacts.CONTENT_URI),PICK_CONTACT);
  </code></pre>
  
  <p>While returning (onActivityResult(int reqCode, int resultCode, Intent data)), I am using details from 'data' to query the contacts through</p>
  
  <pre><code> if (resultCode == Activity.RESULT_OK) {
          Uri contactData = data.getData();
          Cursor c =  managedQuery(contactData, null, null, null, null);
          ......
  </code></pre>
  
  <p>my code works fine with Android 2.x. However this code gets crashed in ICS (Android 4.x), while resuming the main Activity(A).
  I am not sure, whether it is due to the deprecated 'managedQuery'.
  Can somebody offer some solution, I am stuck and unable to even find which line causes the error as the Log cat is not showing even the error line number. it simply says 
   <strong>Caused by: android.database.StaleDataException: Attempted to access a cursor after it has been closed.</strong> 
  Thanks in advance
  Joshy</p>
  
  <p>I have tried the above code just after completing the requirement of the cursor. Still the problem persists. My Log cat says as follows</p>
  
  <pre><code>08-13 00:26:31.427: W/dalvikvm(3176): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
  08-13 00:26:31.447: E/AndroidRuntime(3176): FATAL EXCEPTION: main
  08-13 00:26:31.447: E/AndroidRuntime(3176): java.lang.RuntimeException: Unable to resume activity {com.desquare.sp/com.desquare.sp.SmartPadActivity}: android.database.StaleDataException: Attempted to access a cursor after it has been closed.
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1173)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.os.Handler.dispatchMessage(Handler.java:99)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.os.Looper.loop(Looper.java:137)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.ActivityThread.main(ActivityThread.java:4424)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at java.lang.reflect.Method.invoke(Method.java:511)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at dalvik.system.NativeStart.main(Native Method)
  08-13 00:26:31.447: E/AndroidRuntime(3176): Caused by: android.database.StaleDataException: Attempted to access a cursor after it has been closed.
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.database.BulkCursorToCursorAdaptor.throwIfCursorIsClosed(BulkCursorToCursorAdaptor.java:75)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.database.BulkCursorToCursorAdaptor.requery(BulkCursorToCursorAdaptor.java:144)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.database.CursorWrapper.requery(CursorWrapper.java:186)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.Activity.performRestart(Activity.java:4505)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.Activity.performResume(Activity.java:4531)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
  08-13 00:26:31.447: E/AndroidRuntime(3176):     ... 10 more
  </code></pre>