This code gets contact names and phone numbers, but its easy to alter
it to get more:
package com.phone.list;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Phones;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;
public class PhoneList extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a cursor with all phones
Cursor c = getContentResolver().query(Phones.CONTENT_URI,
null, null, null, null);
startManagingCursor(c);
// Map Cursor columns to views defined in
simple_list_item_2.xml
ListAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, c,
new String[] { Phones.DISPLAY_NAME,
Phones.NUMBER },
new int[] { android.R.id.text1,
android.R.id.text2 });
setListAdapter(adapter);
}
}
On Sep 2, 10:31 am, 娃儿她爸 <[email protected]> wrote:
> Hi all :
>
> I want to read caontacts's Notes,Nickname,Organization,IM,Postal
> address,Email,etc, to send to PC.
>
> I only know use follow code to get ID, dislpay_name, photoID. But
> don't konw how to get the other's info.
>
> who can help me? thanks......
>
> Cursor cur =
> getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
> null, null, null, null);
> cur.moveToPosition(position);
> cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
> cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
> cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
--
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