[Solved] Get Contact Name Through Contact Number [duplicate]


private String getContactNameFromNumber(String number) { 
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));


    Cursor cursor = context.getContentResolver().query(uri, new String[]{PhoneLookup.DISPLAY_NAME},null,null,null);
    if (cursor.moveToFirst())
    {
        name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }   


    return name;

} 

solved Get Contact Name Through Contact Number [duplicate]