Hi all, I am able to retrieve contact name from emulator phonebook using the above code:
____________________________________________________________________________ public class TestContacts extends Activity { /** Called when the activity is first created. */ ContentResolver contentResolver; Cursor cursor; String id, name; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView)findViewById(R.id.txtView); contentResolver = getContentResolver(); cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cursor.getCount() > 0) { while (cursor.moveToNext()) { String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); System.out.println("ID: "+id); String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); System.out.println("Name: "+name); tv.append("ID: "+id+" "+"Name: "+name+"\n"); } } } } ___________________________________________________________________________ But i want to add contact name in emulator phonebook and i tried it using the below code but anyhow i could not able to see the contact name in phonebook where as i also trace out something from logcat. ___________________________________________________________________________ ... ContentValues values = new ContentValues(); values.put(People.NAME, "Test"); Uri uri = getContentResolver().insert(People.CONTENT_URI, values); if(uri == null){ System.out.println("NEW URI"); } ... ___________________________________________________________________________ Infect, when i run the application for adding the new contact, i found this from the logcat: ___________________________________________________________________________ 02-18 13:18:53.667: DEBUG/AccountManagerService(60): bind attempt failed for Session: expectLaunch false, connected false, stats (0/0/0), lifetime 0.082, getAccountsByTypeAndFeatures, legacy_hosted_or_google 02-18 13:18:53.727: ERROR/ContactsProvider(108): Cannot determine the default account for contacts compatibility 02-18 13:18:53.727: ERROR/ContactsProvider(108): android.accounts.AuthenticatorException: bind failure 02-18 13:18:53.727: ERROR/ContactsProvider(108): at android.accounts.AccountManager.convertErrorToException(AccountManager.java: 659) 02-18 13:18:53.727: ERROR/ContactsProvider(108): at android.accounts.AccountManager.access$500(AccountManager.java:53) 02-18 13:18:53.727: ERROR/ContactsProvider(108): at android.accounts.AccountManager$BaseFutureTask $Response.onError(AccountManager.java:566) 02-18 13:18:53.727: ERROR/ContactsProvider(108): at android.accounts.IAccountManagerResponse $Stub.onTransact(IAccountManagerResponse.java:69) 02-18 13:18:53.727: ERROR/ContactsProvider(108): at android.os.Binder.execTransact(Binder.java:287) 02-18 13:18:53.727: ERROR/ContactsProvider(108): at dalvik.system.NativeStart.run(Native Method) 02-18 13:18:54.037: INFO/ContactAggregator(108): Contact aggregation: 1 02-18 13:18:54.197: INFO/ContactAggregator(108): Contact aggregation complete: 1, 157 ms per contact ___________________________________________________________________________ After that i had also tried to run the application for retrieving the contacts from phonebook. It works fine and also giving perfect result but somehow it doesn't show me the contact which i have added named "Test" that i could not find in phonebook. What is really happening inside, i don't know. Can anybody give me any advice or idea or any code to resolve this problem. Please help me out to resolve this problem. Thanks. -- 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