Conflict between two versions with reading contacts in android
<p>I created an application that reads contacts from the phone and it works fine on platform version of 3.1 but it throws NullPointerException when i run it on 2.3.3 platform.Can anyone show me the reason for this error.</p>

<pre><code>ContentResolver cr = getContentResolver();
    Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null,null, null, null);
       while (cur.moveToNext()) {
            String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
                           Cursor phones = cr.query(Phone.CONTENT_URI, null,
               Phone.CONTACT_ID + " = " + id, null, null);
           while (phones.moveToNext()) {
               String number = phones.getString(phones.getColumnIndex(Phone.NUMBER));
               int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));
               System.out.println("Numeber= "+number);
               switch (type) {
                   case Phone.TYPE_HOME:
                       home=number;
                       break;
                   case Phone.TYPE_MOBILE:
                       mobile=number;
                       break;
                   case Phone.TYPE_WORK:
                       work=number;
                       break;                       
                   case Phone.TYPE_OTHER:
                       other=number;
                       break;

           }              

           }
           phones.close();

       }                
</code></pre>

<p>thanks.</p>
