get Lookup For Contact - Android Account

Android examples for Account:Contact Get

Description

get Lookup For Contact

Demo Code

/**/*w ww .  ja  v a2s . c  o  m*/
 * Property of Matt Allen
 * mattallen092@gmail.com
 * http://mattallensoftware.co.uk/
 *
 * This software is distributed under the Apache v2.0 license and use
 * of the Repay name may not be used without explicit permission from the project owner.
 *
 */
//package com.java2s;
import android.content.Context;
import android.database.Cursor;

import android.net.Uri;
import android.provider.ContactsContract;

public class Main {
    public static String getLookupForContact(Context c, String lookupURI) {
        String[] cols = { ContactsContract.Contacts.LOOKUP_KEY };
        Cursor cursor = c.getContentResolver().query(Uri.parse(lookupURI),
                cols, null, null, null);
        cursor.moveToFirst();

        String result = cursor.getString(0);
        cursor.close();

        return result;
    }
}

Related Tutorials