Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.database.Cursor;

public class Main {
    public static boolean isPhoneNumberInContactList(Context context, String phoneNumber) {

        Cursor c = context.getContentResolver().query(Phone.CONTENT_URI, new String[] { Phone.DATA4 },
                Phone.DATA4 + " = ? or " + Phone.DATA1 + " = ?", new String[] { phoneNumber, phoneNumber }, null);

        boolean result = c.moveToFirst();
        c.close();

        return result;
    }
}