Photos getting scaled automatically after updating address book
<p>Here is the code I am using to write a contact PHOTO.  It works.  If I am quick enough after writing it to the address book and go back and read the contact, I get my picture back.</p>

<p>But, after 10 seconds or so, in the debugger you can see an alarm fire and a thread startup and after that goes away if I go read the same contact back, the PHOTO was scaled down from roughly 400x400 down to 96x96.</p>

<p>It looks like there is a trigger firing on the backend to scale the PHOTO after it is written.  Does anyone know a way to get around this or control it?  Or is there a better way of writing a PHOTO that will not cause this scaling trigger?</p>

<p>I am doing this in Android 2.1 on Droid.</p>

<p>In trying to determine if I was writing the PHOTO correctly, I saw that there was a 
ContactsContract.ContactsColumns interface with PHOTO_URI and PHOTO_THUMB_URI members, but I cannot find any way to get at it as the interface is protected and I cannot find any of the joins returning them.  Does anyone how to use them?</p>

<pre><code>    Uri uri = ContactsContract.RawContacts.CONTENT_URI;
    String[] projection = new String[] { BaseColumns._ID };
    String selection = ContactsContract.RawContacts.CONTACT_ID + "=?";
    String[] arguments = new String[] { "" + lContactID };

    Cursor cursor = resolver.query(uri, projection, selection, arguments, null);
    if (cursor != null &amp;&amp; cursor.getCount() &gt; 0)
    {
        while (cursor.moveToNext())
        {
            long rawContactId = cursor.getLong(0);
            int row = -1;
            Uri uri = ContactsContract.Data.CONTENT_URI;
            String[] projection = new String[] { ContactsContract.Data._ID };
            String selection = ContactsContract.Data.RAW_CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE + "'";
            String[] params = new String[] { "" + rawContactId };

            Cursor cursor = resolver.query(uri, projection, selection, params, null);
            if (cursor != null &amp;&amp; cursor.getCount() &gt; 0)
            {
                if (cursor.moveToFirst())
                {
                    row = cursor.getInt(0);
                }
                cursor.close();
            }

            ContentValues values = new ContentValues();
            values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
            values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
            values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, pic);
            values.put(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);

            if (row &gt;= 0)
            {
                resolver.update(ContactsContract.Data.CONTENT_URI, values, ContactsContract.Data._ID + " = " + photoRow, null);
            }
            else
            {
                resolver.insert(ContactsContract.Data.CONTENT_URI, values);
            }
        }
        cursor.close();
        cursor = null;
    }
</code></pre>
