1

I have this code for update:

public Boolean update() {
  try {
   data.put(ContactsContract.Groups.SHOULD_SYNC, true);

   ContentResolver cr = ctx.getContentResolver();
   Uri uri = ContentUris.withAppendedId(ContactsContract.Groups.CONTENT_URI, Long.parseLong(getId()));
   int mid = cr.update(uri, data,_ID+"="+getId(), null);

   // notify registered observers that a row was updated
   ctx.getContentResolver().notifyChange(
     ContactsContract.Groups.CONTENT_URI, null);

   if (-1 == mid)
    return false;

   return true;
  } catch (Exception e) {
   Log.v(TAG(), e.getMessage(), e);
   return false;
  }
 }

I have values in data, I double checked, and for some reason the values are nut pushed out. I also ran a cur.requery(); and I am having

<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>

EDIT 1 One thing to mention, that I need to use:

data.put(ContactsContract.Groups.SHOULD_SYNC, 1);

as the true value there is not accepted, although that is returned when you check the ContentValues.

Pentium10
  • 204,586
  • 122
  • 423
  • 502

2 Answers2

2

I just made something similar work. Instead of

int mid = cr.update(uri, data,_ID+"="+getId(), null);

use

int mid = cr.update(uri, data,null, null)

your uri already has embedded ID information.

user2271769
  • 181
  • 2
  • 7
1

Ok, I figured it down too:

SQLiteException: no such column: res_package: , while compiling: UPDATE groups SET sync4=?, sync3=?, sync2=?, group_visible=?, system_id=?, sync1=?, should_sync=?, deleted=?, account_name=?, version=?, title=?, title_res=?, _id=?, res_package=?, sourceid=?, dirty=?, notes=?, account_type=? WHERE _id=20

The weird thing is that, this column is returned when you Query the content provider. I made the queries to use all returned columns, so I need to make this work somehow.

Pentium10
  • 204,586
  • 122
  • 423
  • 502