Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.provider.ContactsContract; import android.provider.ContactsContract.Intents.Insert; public class Main { public static void addToFacebookContact(Context mContext, ArrayList<String> contactDatas) { /** * ArrayList elements: * * 1. Name 2. Userid 3.Username */ Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT); i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); if (contactDatas.get(2) == null) { contactDatas.set(2, "Facebook name"); } ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues row1 = new ContentValues(); row1.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE); row1.put(ContactsContract.Data.DATA1, contactDatas.get(2)); row1.put(ContactsContract.Data.DATA2, ContactsContract.CommonDataKinds.Im.TYPE_OTHER); row1.put(ContactsContract.Data.DATA5, ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM); row1.put(ContactsContract.Data.DATA6, "Facebook"); row1.put(ContactsContract.Data.DATA10, contactDatas.get(1)); data.add(row1); i.putExtra(Insert.NAME, contactDatas.get(0)); i.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data); mContext.startActivity(i); } }