Contacts not appear in list of Android Phone
<p>I made this code to insert contacts. First name is inserted and then a phone.</p>

<p>The problem is: I do not know if entered. Each time you debug the code, the rawcontactid is incremented (like the time before that right).</p>

<p>But not on the list of default android - phonebook.</p>

<p>Could anyone help me? The following codes:</p>

<pre><code>public static long addNewNameToContact(Context context, String nome) {

    long rawContactId = 0;

    ContentValues values = new ContentValues();
    values.put(RawContacts.ACCOUNT_TYPE, "");
    values.put(RawContacts.ACCOUNT_NAME, "");
    Uri rawContactUri = context.getContentResolver().insert(RawContacts.CONTENT_URI, values);
    rawContactId = ContentUris.parseId(rawContactUri);

    values.clear();
    values.put(Data.RAW_CONTACT_ID, rawContactId);
    values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
    values.put(StructuredName.DISPLAY_NAME, nome);
    context.getContentResolver().insert(Data.CONTENT_URI, values);

    return rawContactId;
}


public void putPhoneInContact(String phone, long id, int phonetipo) {



    Uri contact = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);

    ContentValues values = new ContentValues();

    values.clear();

    // Selecionando o tipo.
    switch (phonetipo) {
    case 0:
        values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
        break;
    case 1:
        values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_HOME);
        break;
    case 2:
        values.put(ContactsContract.CommonDataKinds.Phone.TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_WORK);
        break;
    }

    values.put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone);

    context.getContentResolver().update(contact, values, null, null);

}
</code></pre>

<p>Thanks for the help!</p>
