asked for back ref 0 but there are only 0 back refs

Tutorials with advanced 'difficulty' and more Lines of Code.

asked for back ref 0 but there are only 0 back refs

Postby adhavan » Thu Aug 26, 2010 1:20 pm

hi i am adding a new contact from my application.
but in LOGCAT i am getting the error
Code: Select all
08-24 18:16:44.833: ERROR/ContentProviderOperation(152): mType: 1, mUri: content://, mSelection: null, mExpectedCount: null, mYieldAllowed: false, mValues: data1=xzzsf, mValuesBackReferences: raw_contact_id=0, mSelectionArgsBackReferences: null
[color=#BF0040]08-24 18:16:44.863: ERROR/JavaBinder(152): *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
08-24 18:16:44.863: ERROR/JavaBinder(152): java.lang.ArrayIndexOutOfBoundsException: asked for back ref 0 but there are only 0 back refs[/color]

can anyone please spot what is going worng?
my code to add contact is

Code: Select all
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
        int rawContactInsertIndex = ops.size();
      .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, rawContactInsertIndex)
            .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name)
              .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, phone)
              .withValue(ContactsContract.CommonDataKinds.Phone.TYPE, phoneType)
              .withValue(ContactsContract.CommonDataKinds.Email.DATA, email)
              .withValue(ContactsContract.CommonDataKinds.Email.TYPE, emailType)             
      try {
          getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
          Context ctx = getApplicationContext();
          CharSequence txt = "Contact " + name +" added successfully";
          int duration = Toast.LENGTH_LONG;
          Toast toast = Toast.makeText(ctx, txt, duration);
      } catch (Exception e) {

hey please help me out....... what is the simplest way to add a contact with code????? i have also attached the image of my error in LOGCAT.

loads of thanks in advance
Error Thrown
LogCAT.png (85.72 KiB) Viewed 731 times
Posts: 7
Joined: Thu Aug 26, 2010 1:03 pm


Return to Advanced Tutorials

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests