title: Will Save Contact work in Android Emulator?
body: <p>I'm trying to add a contact from Android Webview HTML page. I made use of Javascript interface for calling Android function from the HTML/Javascript.. Below is the code in JSInterface.java which will be called from Javascript,</p>
  
  <pre><code>    public void addContact(String name, String mobile){
          String msg = "";
          ContentValues cv = new ContentValues();
          cv.put(Contacts.People.NAME, name);
          Uri newPersonUri = Contacts.People.createPersonInMyContactsGroup(mContext.getContentResolver(), cv);
          if (newPersonUri != null) {
              ContentValues mobileValues = new ContentValues();
              Uri mobileUri = Uri.withAppendedPath(newPersonUri,Contacts.People.Phones.CONTENT_DIRECTORY);
              mobileValues.put(Contacts.Phones.NUMBER,mobile);
              mobileValues.put(Contacts.Phones.TYPE,Contacts.Phones.TYPE_MOBILE);
              Uri phoneUpdate = mContext.getContentResolver().insert(mobileUri, mobileValues);
              if (phoneUpdate == null) {
                  msg = "Failed to add Contact";
              }
          }
          msg = "Contact added successfully";
              Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
  
      }   
  </code></pre>
  
  <p>When I call the function from javascript the application is aborted abruptly. Following exception trace is printed in LogCat,</p>
  
  <pre><code>12-08 12:59:59.610: I/dalvikvm(1259): java.lang.IllegalStateException: Failed to find the My Contacts group
  12-08 12:59:59.610: I/dalvikvm(1259):   at android.provider.Contacts$People.addToMyContactsGroup(Contacts.java:491)
  12-08 12:59:59.610: I/dalvikvm(1259):   at android.provider.Contacts$People.createPersonInMyContactsGroup(Contacts.java:568)
  12-08 12:59:59.610: I/dalvikvm(1259):   at com.android.contactmanager.JSInterface.addContact(JSInterface.java:89)
  12-08 12:59:59.610: I/dalvikvm(1259):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
  12-08 12:59:59.620: I/dalvikvm(1259):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
  12-08 12:59:59.620: I/dalvikvm(1259):   at android.webkit.WebViewCore.access$3900(WebViewCore.java:55)
  12-08 12:59:59.620: I/dalvikvm(1259):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1370)
  12-08 12:59:59.620: I/dalvikvm(1259):   at android.os.Handler.dispatchMessage(Handler.java:99)
  </code></pre>
  
  <p>I don't have Android device right now, so I'm using Android Emulator to test the app.. Do "Save Contact" work in Android emulator? If so what is the problem with my code? Any help??</p>
  
  <p>TIA.</p>