How do I create a user profile in ContactsContract?
<p>I am trying to create a user profile in ContactsContract...because there is not one, and I need one for testing.  I don't have a real-life Android device, and only have the AVD Emulator for testing.</p>

<p>Here is the code block that I am working from:</p>

<pre><code>ArrayList&lt;ContentProviderOperation&gt; ops = new ArrayList&lt;ContentProviderOperation&gt;();

ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
    .withValue(RawContacts.ACCOUNT_TYPE, null)
    .withValue(RawContacts.ACCOUNT_NAME, null)
    .build());        

ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
    .withValueBackReference(Data.RAW_CONTACT_ID, 0)
    .withValue(Data.MIMETYPE, Profile.CONTENT_RAW_CONTACTS_URI)
    .withValue(Profile.IS_USER_PROFILE, 1)
    .build()); 

ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
    .withValueBackReference(Data.RAW_CONTACT_ID, 0)
    .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
    .withValue(StructuredName.DISPLAY_NAME, name)
    .build());

this.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
</code></pre>

<p>If you remove the lines for making this entry a user profile, it works fine (i.e., will insert the name).  However, I can not figure out how to set the entry with the IS_USER_PROFILE flag.</p>

<p>Can you create a user profile from an App?  If so, any ideas on why this won't work?</p>

<p>Many thanks!
Scott</p>
