Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-5278

Contacts.remove : Cursor is not closed.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 3.1.0
    • None
    • cordova-android
    • Android 4.1.2

    Description

      When I run Contact mobile-spec tests, I got following warning message.

      11-05 10:30:32.890: W/CursorWrapperInner(2524): Cursor finalized without prior close()

      I think this is because cursor is not closed at remove(). After close() is added, I don't get this message.

      ContactAccessorSdk5.java
          public boolean remove(String id) {
              int result = 0;
              Cursor cursor = mApp.getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
                      null,
                      ContactsContract.Contacts._ID + " = ?",
                      new String[] { id }, null);
              if (cursor.getCount() == 1) {
                  cursor.moveToFirst();
                  String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
                  Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
                  result = mApp.getActivity().getContentResolver().delete(uri, null, null);
              } else {
                  Log.d(LOG_TAG, "Could not find contact with ID");
              }
      
              //ST Added
              cursor.close();
      
              return (result > 0) ? true : false;
          }
      

      Attachments

        Activity

          People

            bowserj Joey Robert Bowser
            shingot Shingo Toda
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: