Null pointer Exception
<p>I am trying to pick the display name, mobile number from the contacts in phone and showing these in a list by using a list view. But I'm getting null pointer exception while running the following code:</p>

<pre><code>public class SeeActivity extends ListActivity {
    public String [] allname;
       public String [] allnumber;
       public int listcount=0;
       public String [] details;
       String[] PROJECTION = new String[] {
               ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
               ContactsContract.CommonDataKinds.Phone.NUMBER




       };
      @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


;

        Cursor phone= getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,PROJECTION ,null ,null ,null);

       try{
        while(phone.moveToNext())
        {  

           String name= phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
           String number=phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
           allname[listcount]=name;
           allnumber[listcount]=number;
           details [listcount]=name+"    "+number;
           listcount=listcount+1;

        }
        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                android.R.layout.simple_list_item_1,details);
        setListAdapter(adapter);
        ListView l=getListView();
           l.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                    long arg3) {
                Toast.makeText(getApplicationContext(),((TextView)arg1).getText() , Toast.LENGTH_SHORT).show();



           }
        });}
       catch( Exception e)
       {
           Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_LONG).show();   
       }



    }


}
</code></pre>
