title: get owner user name and phone number using account manager in android
body: <p>get owner user name and phone number using account manager in android </p>
  
  <p>here is my code..</p>
  
  <pre><code>public void OwnerInfo() {
  
       final AccountManager manager = AccountManager.get(this);
          final Account[] accounts = manager.getAccountsByType("com.google");
          final int size = accounts.length;
          String[] names = new String[size];
          for (int i = 0; i &lt; size; i++) {
            names[i] = accounts[i].name;
          }
          if (names[0] != null) {
              accountName = names[0];
  
              ContentResolver cr = this.getContentResolver();
              Cursor emailCur = cr.query(
                      ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
                      ContactsContract.CommonDataKinds.Email.DATA + " = ?",
                      new String[] { accountName }, null);
              while (emailCur.moveToNext()) {
                  id = emailCur
                          .getString(emailCur
                                  .getColumnIndex(ContactsContract.CommonDataKinds.Email.CONTACT_ID));
                  email = emailCur
                          .getString(emailCur
                                  .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
                  String newName = emailCur
                          .getString(emailCur
                                  .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                  if (name == null || newName.length() &gt; name.length())
                      name = newName;
  
                  Log.v("Got contacts", "ID " + id + " Email : " + email
                          + " Name : " + name);
              }
  
              emailCur.close();
              if (id != null) {
  
                  // get the phone number
                  Cursor pCur = cr.query(
                          ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                          null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                  + " = ?", new String[] { id }, null);
                  while (pCur.moveToNext()) {
                      phone = pCur
                              .getString(pCur
                                      .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                      Log.v("Got contacts", "phone" + phone);
                  }
                  pCur.close();
              }
          }
      }
  </code></pre>
  
  <p>but its show the error that..</p>
  
  <pre><code>08-22 11:47:36.392: E/AndroidRuntime(434): FATAL EXCEPTION: main
  08-22 11:47:36.392: E/AndroidRuntime(434): java.lang.ArrayIndexOutOfBoundsException
  08-22 11:47:36.392: E/AndroidRuntime(434):  at com.param.calltracker.SettingsActivity.OwnerInfo(SettingsActivity.java:142)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at com.param.calltracker.SettingsActivity$1.onClick(SettingsActivity.java:78)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.view.View.performClick(View.java:2485)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.view.View$PerformClick.run(View.java:9080)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.os.Handler.handleCallback(Handler.java:587)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.os.Handler.dispatchMessage(Handler.java:92)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.os.Looper.loop(Looper.java:123)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at java.lang.reflect.Method.invoke(Method.java:507)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  08-22 11:47:36.392: E/AndroidRuntime(434):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>where is the error in my code..pls help me..</p>