I also meet the similar problem with
Contacts.ContactMethods.CONTENT_EMAIL_URI, but it works fine with
Contacts.ContactMethods.CONTENT_URI. My code is:

Uri uri = Contacts.ContactMethods.CONTENT_URI;
String selection = Contacts.ContactMethods.KIND + "=" +
Contacts.ContactMethods.EMAIL_KIND
Cursor c = this.getContentResolver().query(uri, EMAIL_PROJECTION, selection,
null, null);

2008/4/6, Maxim Yudin <[EMAIL PROTECTED]>:
>
>
>
> I write new article abotu using Content Provider. I get info about
> person's name and person's phones in contact list. But I can not get e-
> mail of person. Help. I have found URI -
> Contacts.ContactMethods.CONTENT_EMAIL_URI, but it not help
>
> My code:
>
> Java:
>
> package maximyudin.contentproviderexample;
>
> import android.app.Activity;
> import android.content.Context;
> import android.content.ContentUris;
> import android.database.Cursor;
> import android.net.Uri;
> import android.os.Bundle;
> import android.provider.Contacts;
> import android.provider.Contacts.People;
> import android.provider.Contacts.PeopleColumns;
> import android.widget.ExpandableListAdapter;
> import android.widget.ExpandableListView;
> import android.widget.SimpleCursorTreeAdapter;
> import android.widget.TabHost;
> import android.widget.TabHost.TabSpec;
>
> public class ContentProviderExample extends Activity {
>         private int mGroupIdColumnIndex;
>
>         private String mPhoneNumberProjection[] = new String[] {
>                 People.Phones._ID, People.Phones.NUMBER
>         };
>
>         private ExpandableListAdapter mAdapter;
>
>         @Override
>         public void onCreate(Bundle icicle) {
>             super.onCreate(icicle);
>             setContentView(R.layout.main);
>
>             TabHost tabs = (TabHost)this.findViewById(R.id.tabs);
>             tabs.setup();
>
>             TabSpec one = tabs.newTabSpec("one");
>             one.setContent(R.id.content1);
>             one.setIndicator("Contacts",
> this.getResources().getDrawable(R.drawable.person));
>             tabs.addTab(one);
>
>             TabHost.TabSpec two = tabs.newTabSpec("two");
>             two.setContent(R.id.content2);
>             two.setIndicator("Empty");
>             tabs.addTab(two);
>             tabs.setCurrentTab(0);
>
>             final ExpandableListView contactlist =
>
> (ExpandableListView)this.findViewById(R.id.contactlist);
>
>             // Query for people
>             Cursor groupCursor = managedQuery(People.CONTENT_URI,
>                     new String[] {People._ID, People.NAME}, null,
> null, null);
>
>             // Cache the ID column index
>             mGroupIdColumnIndex =
> groupCursor.getColumnIndex(People._ID);
>
>             // Set up our adapter
>             mAdapter = new MyExpandableListAdapter(groupCursor,
>                     this,
>                     android.R.layout.simple_expandable_list_item_1,
>                     android.R.layout.simple_expandable_list_item_1,
>                     new String[] {People.NAME}, // Name for group
> layouts
>                     new int[] {android.R.id.text1},
>                     new String[] {People.NUMBER}, // Number for child
> layouts
>                     new int[] {android.R.id.text1});
>
> contactlist.setAdapter(mAdapter);
>         }
>
>         public class MyExpandableListAdapter extends
> SimpleCursorTreeAdapter {
>             public MyExpandableListAdapter(Cursor cursor, Context
> context, int groupLayout,
>                     int childLayout, String[] groupFrom, int[]
> groupTo, String[] childrenFrom,
>                     int[] childrenTo) {
>                 super(context, cursor, groupLayout, groupFrom,
> groupTo, childLayout, childrenFrom,
>                         childrenTo);
>             }
>
>             @Override
>             protected Cursor getChildrenCursor(Cursor groupCursor) {
>                 // Given the group, we return a cursor for all the
> children within that group
>
>                 // Return a cursor that points to this contact's
> phone numbers
>                 Uri.Builder builder = People.CONTENT_URI.buildUpon();
>                 ContentUris.appendId(builder,
> groupCursor.getLong(mGroupIdColumnIndex));
>
> builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
>                 Uri phoneNumbersUri = builder.build();
>
>                 // The returned Cursor MUST be managed by us, so we
> use Activity's helper
>                 // functionality to manage it for us.
>                 return managedQuery(phoneNumbersUri,
> mPhoneNumberProjection, null, null, null);
>             }
>         }
> }
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to