Reputation: 31
I'm trying to read all the contacts stored in the phone using this code:
Cursor cursorNumber = context.getContentResolver().query( Contacts.Phones.CONTENT_URI, new String[] { Contacts.Phones._ID, Contacts.Phones.NAME, Contacts.Phones.NUMBER }, null, null, null );
but the result seems empty until the moment I sync the contacts with Google. Is that possible? Is it a limitation of Google Contacts API?
Upvotes: 3
Views: 1303
Reputation: 7117
cname = managedQuery(People.CONTENT_URI, null, null, null, null);
String[] from = new String[] {People.NAME};
int[] to = new int[] { R.id.text_view };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.contactlist,cname,from,to);
lv = (ListView)findViewById(R.id.list_view);
lv.setAdapter(adapter);
if (cname.moveToFirst()) {
String name = cname.getString(cname.getColumnIndexOrThrow(People.NAME));
System.out.println("@@@@@ name" + name);
}
if (cname.moveToFirst()) {
String name = cname.getString(cname.getColumnIndexOrThrow(People.NAME));
System.out.println("@@@@@ name" + name);
}
Upvotes: 0
Reputation: 782
for an example using the new contactscontract api you can visit http://code.google.com/p/android-contacts-contract-example/ where all contacts and information is queried
Upvotes: 0