tags:

views:

15

answers:

0

Hi! I am inserting contact using below mention code, In contacts newly added contact is not visible while when i use contact picker using this code startActivity(new Intent(Intent.ACTION_PICK, People.CONTENT_URI); it is showing newly added contact. Please guide what wrong in code

ContentValues values = new ContentValues();
                values.put(People.NAME, name);
                Uri uri = this.cr.insert(People.CONTENT_URI, values);

                Uri phoneUri = null;
                Uri emailUri = null;

                phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);

                values.clear();         
                values.put(People.Phones.TYPE, People.Phones.TYPE_MOBILE);
                values.put(People.Phones.NUMBER, phoneNumber);          
                this.cr.insert(phoneUri, values);

                emailUri = Uri.withAppendedPath(uri, People.ContactMethods.CONTENT_DIRECTORY);

                values.clear();

                values.put(People.ContactMethods.KIND, Contacts.KIND_EMAIL);
                values.put(People.ContactMethods.TYPE, People.ContactMethods.TYPE_HOME);
                values.put(People.ContactMethods.DATA, email);

                this.cr.insert(emailUri, values);