Java 两个版本之间的冲突与android中的reading contacts

Java 两个版本之间的冲突与android中的reading contacts,java,android,Java,Android,我创建了一个从手机读取联系人的应用程序,它在3.1平台上运行良好,但在2.3.3平台上运行时会抛出NullPointerException。有人能告诉我此错误的原因吗 ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null,null, null, null); while (cur.moveToNext()) {

我创建了一个从手机读取联系人的应用程序,它在3.1平台上运行良好,但在2.3.3平台上运行时会抛出NullPointerException。有人能告诉我此错误的原因吗

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();

       }                
谢谢。

使用URI“Phone.CONTENT\u URI”。正在对其进行2.3.3或2.2.1测试