Tutorial :Android 2.0: how to add contact groups in the emulator?



Question:

how to add contact groups in the emulator or sync with Google contacts or device contacts?


Solution:1

As far as I know you can't.

You have to get a free application that does this and push to the emulator. You can use the Contacts->Import from VCF function to import contacts from a vcard file.


Solution:2

  1. Create a local contact on you android emulator
  2. Run this code/app to your emulator:

    // ------------------------------------------------------ Create Google // Group ()

    public void createGoogleGroup(String groupName) {  ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();ops = new Arraenter code hereyList<ContentProviderOperation>();    ops.add(ContentProviderOperation          .newInsert(ContactsContract.Groups.CONTENT_URI)          .withValue(ContactsContract.Groups.TITLE, groupName)          .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE,                  "com.google")          .withValue(ContactsContract.RawContacts.ACCOUNT_NAME,                  googleAccountName).build());  try {        context.getContentResolver().applyBatch(ContactsContract.AUTHORITY,              ops);    } catch (Exception e) {      Log.e("Error Creating Group", e.toString());  }}  

    Hope it helpes


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »