import android.app.Activity; import android.content.ContentUris; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.Contacts.People; import android.util.Log;
public class Start extends Activity { /** Called when the activity is first created. */ public static final String[] METHODS_PROJECTION = new String[] { People.ContactMethods._ID, People.ContactMethods.KIND, People.ContactMethods.DATA, People.ContactMethods.TYPE, People.ContactMethods.LABEL, People.ContactMethods.ISPRIMARY, }; Uri mUri; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mUri = ContentUris.withAppendedId(Uri.parse("content://contacts/ people"), 1); //1 is the ID of the first created contact Uri methodsUri = Uri.withAppendedPath(mUri, People.ContactMethods.CONTENT_DIRECTORY); Cursor methodsCursor = getContentResolver().query (methodsUri,METHODS_PROJECTION, "kind=1", null, null); Log.i("Cursor", "Count = " + methodsCursor.getCount()); } } On Feb 4, 4:44 am, dileep singh <discover.dile...@gmail.com> wrote: > Hi Mark, > Can u give me some sample code?I am not able to get email with the above > code. > please provide me somple code > > On Wed, Feb 4, 2009 at 12:53 AM, dileep singh > <discover.dile...@gmail.com>wrote: > > > Thanks a lot mark.I will try the above code. > > > On Tue, Feb 3, 2009 at 10:46 PM, Mark Roberts <snappe...@gmail.com> wrote: > > >> If you are looking for the emails for a specific contact then you > >> could do it like this where id is the id of the contact for which you > >> are trying to get the data: > > >> public static final String[] METHODS_PROJECTION = new String[] { > >> People.ContactMethods._ID, > >> People.ContactMethods.KIND, > >> People.ContactMethods.DATA, > >> People.ContactMethods.TYPE, > >> People.ContactMethods.LABEL, > >> People.ContactMethods.ISPRIMARY, > >> }; > >> mUri = ContentUris.withAppendedId(Uri.parse("content://contacts/ > >> people"), id) > >> Uri methodsUri = Uri.withAppendedPath(mUri, > >> People.ContactMethods.CONTENT_DIRECTORY); > >> Cursor methodsCursor = getContentResolver().query(methodsUri, > >> METHODS_PROJECTION, "kind=1", null, null); > > >> On Feb 3, 12:05 pm, dilu <discover.dile...@gmail.com> wrote: > >> > Hi, > >> > Please tell me how to get lists of email from contact application in > >> > android?If possible then please provide me some sample code or > >> > tutorial on this. > >> > please help me. > >> > Thanks > >> > dileep --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---