Your query does not constrain the mime type, so it will return all
kinds of Data (emails, phones, names etc). Please take a look at this
document:

http://developer.android.com/reference/android/provider/ContactsContract.Data.html

It provides an example of how to run the query you need.

BTW, passing null for projection (columns) is typically not a good
idea, it can be very expensive and certainly is very expensive if all
you need is a phone number.

I hope this helps,
- Dmitri



On Sun, Dec 6, 2009 at 1:31 PM, dane131 <[email protected]> wrote:
> anybody help?
>
> On Dec 6, 6:37 pm, dane131 <[email protected]> wrote:
>> i created a contact in my avd and run the following application
>>
>> package com.example.contents;
>>
>> import java.util.Queue;
>>
>> import android.app.Activity;
>> import android.database.Cursor;
>> import android.net.Uri;
>> import android.os.Bundle;
>> import android.provider.ContactsContract.Data;
>> import android.provider.ContactsContract.CommonDataKinds.Phone;
>> import android.provider.ContactsContract.CommonDataKinds.Email;
>> import android.widget.TextView;
>>
>> public class ContentProviders extends Activity {
>>     /** Called when the activity is first created. */
>>     @Override
>>     public void onCreate(Bundle savedInstanceState) {
>>         super.onCreate(savedInstanceState);
>>         Uri contacts= Data.CONTENT_URI;
>>         TextView phone=null;
>>         Cursor cur = managedQuery(contacts, null, null, null, null);
>>         if(cur.moveToFirst()) //if cur!=null
>>         {
>>                 do {
>>
>>                         phone=new TextView(this);
>>                         phone.setText(cur.getString(cur.getColumnIndex
>> (Phone.NUMBER)));
>>                         setContentView(phone);
>>
>>                 }while(cur.moveToNext());
>>         }
>>
>>     }
>>
>> }
>>
>> But instead of the phone the name of the contact is returned.I also
>> tried to get the email from my contact but it didn't show
>> anything.What i am doing wrong?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to