title: Application has stopped unexpectedly with Force close?
body: <p>When I am running a program in android 2.1. I got an error <strong>Application has stopped unexpectedly</strong> then force close.I clean the project again and again then build but the issue still remains.This program need to display the <strong>Email Address</strong> of all the contacts from the emulator on the ListView.</p>
  
  <p><strong>code</strong></p>
  
  <pre><code>public class Trial3 extends Activity {
  
  ListView lvItem;
  private Button btnAdd;
  String displayName="", emailAddress="", phoneNumber="";
  ArrayList&lt;String&gt; contactlist=new ArrayList&lt;String&gt;();
  ArrayAdapter&lt;String&gt; itemAdapter;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
     lvItem = (ListView)this.findViewById(R.id.listview);  
     btnAdd = (Button)this.findViewById(R.id.btn);
     itemAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,contactlist);
     lvItem.setAdapter(itemAdapter);
     btnAdd.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             GetEmails();
             Toast.makeText(Trial3.this, "working...", Toast.LENGTH_SHORT).show();
         }
     }); 
  }
  
  private void GetEmails()
  {
      ContentResolver cr =getContentResolver();
      Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
      while (cursor.moveToNext()) 
      {       
          String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
          Cursor emails = cr.query(Email.CONTENT_URI,null,Email.CONTACT_ID + " = " + id, null, null);
          while (emails.moveToNext()) 
          {               
              emailAddress = emails.getString(emails.getColumnIndex(Email.DATA));
              contactlist.add(emailAddress);
              itemAdapter.notifyDataSetChanged();
          }
          emails.close();
  
      }
      cursor.close(); 
  }
  }
  </code></pre>
  
  <p><strong>Logcat</strong></p>
  
  <pre><code> 06-14 15:03:17.339: D/AndroidRuntime(502): Shutting down VM
   06-14 15:03:17.339: W/dalvikvm(502): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
   06-14 15:03:17.339: E/AndroidRuntime(502): Uncaught handler: thread main exiting due to uncaught exception
   06-14 15:03:17.349: E/AndroidRuntime(502): java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=502, uid=10028 requires android.permission.READ_CONTACTS
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.os.Parcel.readException(Parcel.java:1218)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.content.ContentProviderProxy.bulkQuery(ContentProviderNative.java:326)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.content.ContentProviderProxy.query(ContentProviderNative.java:345)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.content.ContentResolver.query(ContentResolver.java:202)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at com.abhi.Trial3.GetEmails(Trial3.java:45)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at com.abhi.Trial3.access$0(Trial3.java:42)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at com.abhi.Trial3$1.onClick(Trial3.java:36)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.view.View.performClick(View.java:2364)
   06-14 15:03:17.349: E/AndroidRuntime(502):     at android.view.View.onTouchEvent(View.java:4179)
  </code></pre>
  
  <p>How to solve this problem ?</p>