Hello,
A few weeks ago I asked exactly the same question here. At first, I thought the answers solved my problem, but they didn't. I just didn't notice that I wasn't able to solve my problem with those answers.
However, what I've got now is:
final Cursor phoneCursor = context.getContentResolver().query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode("'" + incomingNumber + "'")), null, null, null, null);
phoneCursor.moveToFirst();
String lookupString = phoneCursor.getString(phoneCursor.getColumnIndex(PhoneLookup.LOOKUP_KEY));
final Cursor dataCursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, ContactsContract.Data.LOOKUP_KEY + "=" + "'" + lookupString + "'", null, null);
dataCursor.moveToFirst();
Log.e("smn", "display_name: " + dataCursor.getString(dataCursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)));
Log.e("smn", "nickname: " + dataCursor.getString(dataCursor.getColumnIndex(ContactsContract.Data.DATA1)));
Output looks like this:
08-14 17:41:02.106: ERROR/smn(20146): display_name: Tom Tasche
08-14 17:41:02.106: ERROR/smn(20146): nickname: null
This answer told me that Nicknames are held in Data-table, but although I'm querying Data-table, I don't retrieve the contact's alias saved in my addressbook.
I already tried it the other way: I inserted a new alias for this contact. And that worked fine. So, nicknames seem to work. Additionally, I've printed out every field that's saved in Data-table, again, without no luck.
Any ideas? Maybe I'm doing something completely wrong, but at the moment I don't see what's the problem...
Thanks for your help
Tom