How to Get Contact Image in Android.

This simple example gets the image from contacts in android.

private void getContactsDetails() {

		Cursor phones = getContentResolver().query(
				ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,
				null, null);
		while (phones.moveToNext()) {
			String Name = phones
			String Number = phones

			String image_uri = phones

			System.out.println("Contact1 : " + Name + ", Number " + Number
					+ ", image_uri " + image_uri);
			if (image_uri != null) {


Please leave your valuable comments.

How to find your Google Plus ID

This is so simple

1. Go to your Google + account (

2. Click on the Profile icon on the Left.

3. If you look at the URL in the address bar, it should look something like this:

4. The long numerical string in the URL is your Google+ ID. Here is CoderzHeaven’s from the URL above:


Google + CoderzHeaven

How to delete a contact in android?

Hello all previously I have shown how to list all contacts in your phone and in another post I showed how to programatically create a contact in android.
In today’s tutorial I will show you how to delete a contact in android programatically.

This simple code does that.

 public static boolean deleteContact(Context ctx, String phone, String name) {
        Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phone));
        Cursor cur = ctx.getContentResolver().query(contactUri, null, null, null, null);
        try {
            if (cur.moveToFirst()) {
                do {
                    if (cur.getString(cur.getColumnIndex(PhoneLookup.DISPLAY_NAME)).equalsIgnoreCase(name)) {
                        String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
                        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
                        ctx.getContentResolver().delete(uri, null, null);
                        return true;

                } while (cur.moveToNext());

        } catch (Exception e) {
        return false;

How to add a new contact programmatically in android?

We all know how to add a new contact to our android devices without programming right.
OK that’s a normal man’s use.
But what from a programmer’s view.

This is the sample java code that helps you to add contact programatically.

package com.coderzheaven.pack;

import java.util.ArrayList;

import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.Contacts.People;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.widget.Toast;

public class AddContactDemo extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
   private void addContact(String name, String phone) {
        ContentValues values = new ContentValues();
        values.put(People.NUMBER, phone);
        values.put(People.TYPE, Phone.TYPE_CUSTOM);
        values.put(People.LABEL, name);
        values.put(People.NAME, name);
        Uri dataUri = getContentResolver().insert(People.CONTENT_URI, values);
        Uri updateUri = Uri.withAppendedPath(dataUri, People.Phones.CONTENT_DIRECTORY);
        values.put(People.Phones.TYPE, People.TYPE_MOBILE);
        values.put(People.NUMBER, phone);
        updateUri = getContentResolver().insert(updateUri, values);

After running this programs please switch to contacts application on your device to see the result.

Add Contacts

Please leave your comments and also share it if you like it.