Back to project page wiki-contacts-android.
The source code is released under:
Apache License
If you think the Android project wiki-contacts-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kahkong.wikicontacts.service; //from w ww . j a va2 s. com import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract.PhoneLookup; /** * * @author Poh Kah Kong * */ public class PhoneBookServiceImpl implements PhoneBookService { private static PhoneBookService instance; private Context context; private PhoneBookServiceImpl() { } public synchronized static PhoneBookService getInstance() { if (instance==null) { instance = new PhoneBookServiceImpl(); } return instance; } public boolean isContactExists(String number) { Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); String[] mPhoneNumberProjection = { PhoneLookup._ID, PhoneLookup.NUMBER, PhoneLookup.DISPLAY_NAME }; Cursor cur = context.getContentResolver().query(lookupUri,mPhoneNumberProjection, null, null, null); try { if (cur.moveToFirst()) { return true; } } finally { if (cur!= null) cur.close(); } return false; } public void setContext(Context context) { this.context = context; } }