Android - Get Nickname and Type of Nickname
<p>I've been trying to get the nickname of a contact for a few hours now, and still cant get them to work, I've been told that they are in a differnt table to the phone numbers etc.. But i dont know how to access them.</p>

<p>The closest I've got is this..</p>

<pre><code>Cursor cursor = context.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts._ID +" = ?", new String[]{String.valueOf(recordId)}, null);
    while (cursor.moveToNext()) {
       Cursor nickname = context.getContentResolver().query( ContactsContract.Data.CONTENT_URI, null, ContactsContract.CommonDataKinds.Nickname.CONTACT_ID +" = "+ recordId, null, null); 
       while (nickname.moveToNext()) { 
           try {
           String nicknameName = nickname.getString(nickname.getColumnIndex(ContactsContract.CommonDataKinds.Nickname.NAME));
           String nicknameType = nickname.getString(nickname.getColumnIndex(ContactsContract.CommonDataKinds.Nickname.TYPE));

           switch (Integer.valueOf(nicknameType)) {
           case 1: nicknameType = "TYPE_HOME"; break;
           }
           list.add(new KeyValue("Nickname:" + nicknameType, nicknameName));
           } catch (Exception e) { continue; }
       }
       nickname.close();
    }
</code></pre>

<p>This gets all the data of the contact along with the type eg: <code>Thomas Owers</code> <code>1</code> this is all good but it doesn't give me what the data is, so it gives the email, phone, names, nickname but i cant distinguish between them.</p>

<p>Any help would be much apreciated, Thank you! :)</p>
