I have been practicing on contacts reading in android and I am getting the contacts and the numbers but they are not arranged well. I mean the names assigned are not of the owners of the numbers. here is my code:
String [] projection= new String[]{ContactsContract.Contacts.DISPLAY_NAME,};
    String [] phoneProjection= new String [] {Phone.NUMBER};
     ContentResolver crInstance=getContentResolver();
    final  Cursor name=crInstance.query(ContactsContract.Contacts.CONTENT_URI, projection, null, null, null);
    final Cursor phone=crInstance.query(Phone.CONTENT_URI, phoneProjection, null, null, null);
    contactview = (TextView) findViewById(R.id.contactview);
    name.moveToFirst();
    phone.moveToFirst();
    while (!name.isAfterLast()&&!phone.isAfterLast()){
        String pname=name.getString(name.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
        contactview.append("Name:");
        contactview.append(pname);
        contactview.append("\n");
        final int contactNoColIndex= phone.getColumnIndex(Phone.NUMBER);
        String pnumber=phone.getString(contactNoColIndex);
        contactview.append("Phone:");
        contactview.append(pnumber);
        contactview.append("\n");
        contactview.append("\n");
        name.moveToNext();
        phone.moveToNext();
    }
    name.close();
    phone.close();
please help
 
    