contactscontract

How to retrieve all contacts details from Content provider with single query?

痞子三分冷 提交于 2021-01-06 03:28:53
问题 I need to read the contacts from device. The fields I required are ID , Display Name , Phone Number (All types) Email id (All types) and 'photo'. For this right now I am doing like this. 1 : First I am reading all the id s from ContactsContract.Contacts.CONTENT_URI; as shown below Uri contactsUri = ContactsContract.Contacts.CONTENT_URI; // Querying the table ContactsContract.Contacts to retrieve all the contacts String[] projection = {ID}; Cursor contactsCursor = mContentResolver.query

How to retrieve all contacts details from Content provider with single query?

◇◆丶佛笑我妖孽 提交于 2021-01-06 03:27:30
问题 I need to read the contacts from device. The fields I required are ID , Display Name , Phone Number (All types) Email id (All types) and 'photo'. For this right now I am doing like this. 1 : First I am reading all the id s from ContactsContract.Contacts.CONTENT_URI; as shown below Uri contactsUri = ContactsContract.Contacts.CONTENT_URI; // Querying the table ContactsContract.Contacts to retrieve all the contacts String[] projection = {ID}; Cursor contactsCursor = mContentResolver.query

How to share a contact programatically in android

梦想的初衷 提交于 2020-02-29 03:12:15
问题 I am presently working on a contact app and i have been searching for a while to share a contact programatically in android. I didn't know in which format i should send the contact to other device. If i am sending as text, how it will be processed into contactscontract Db in receivers device? Can you please suggest me how to make it work? 回答1: You need to get the VCard handle for the contact (using ContactsContract API: Contacts.CONTENT_VCARD_URI ), and then send it using the ACTION_SEND

How to share a contact programatically in android

人走茶凉 提交于 2020-02-29 03:11:50
问题 I am presently working on a contact app and i have been searching for a while to share a contact programatically in android. I didn't know in which format i should send the contact to other device. If i am sending as text, how it will be processed into contactscontract Db in receivers device? Can you please suggest me how to make it work? 回答1: You need to get the VCard handle for the contact (using ContactsContract API: Contacts.CONTENT_VCARD_URI ), and then send it using the ACTION_SEND

How to display phone contacts only (exclude SIM contacts)

二次信任 提交于 2020-01-21 15:18:26
问题 I'm building an UI where I need to show a list of phone contacts in a list view. I'm using ContactsContract.Data and the CursorLoader to load the data and then binding the cursor to a custom adapter (extended off of SimpleCursorAdapter ). The issue here is that I can't figure out how to filter out the SIM contacts; a test phone I have has identical contacts on the phone as well as the SIM, which causes the listview to have duplicate entries. If I remove the SIM, the duplicates go away. How

Android Launching Contacts Application

懵懂的女人 提交于 2020-01-10 04:44:05
问题 I wanna launch the Contacts application from my application Activity. I am not able to understand how to do it. Button contact = (Button) findViewById(R.id.contact); contact.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent i4 = new Intent(); i4.setAction(Intent.ACTION_VIEW); i4.addCategory(Intent.CATEGORY_DEFAULT); i4.setType("vnd.android.cursor.dir/phone"); startActivity(i4); } }); Error: 回答1: void showContacts() { Intent i = new Intent(); i

How to uniquely identify a contact on ContactsContract.Contacts table

故事扮演 提交于 2020-01-05 08:16:51
问题 I have an app that gets the ContactsContract.Contacts.LOOKUP_KEY of a contact on the device and saves it on the app Db. After reading this page I thought I could use the LOOKUP_KEY to uniquely identify a contact, even when a contact is edited (for example after editing the name of the contact). Actually I saw that after editing a contact, its LOOKUP_KEY changes, so I cannot use anymore the LOOKUP_KEY I saved on my app DB. My question is: is there a way to uniquely identify a contact on

Android ContactsContract class: How to ignore non-primary ACCOUNT_TYPES?

杀马特。学长 韩版系。学妹 提交于 2019-12-31 03:03:24
问题 So I know by now that I can use ContactsContract class to list all contacts available on an android device. Something like this: private void getContacts(){ ContentResolver resolver = getContentResolver(); Cursor cursor = resolver.query(ContactsContract.contacts.CONTENT_URI,null,null,null,null); while(cursor.moveToNext){ //get contact id ..... //get contact name .... } } What do I mean by contact above: A contact according to my understanding is a set of raw_contacts . Example: These are 2

Android - cant get phone number of some contacts

≯℡__Kan透↙ 提交于 2019-12-30 11:49:50
问题 I'm having a problem with extracting phone numbers of some people in my contact list. First I show all the contacts in a listview: String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; mCursor = mContext.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, ContactsContract.CommonDataKinds

Get first and last name of a contact rather than single display name?

北城余情 提交于 2019-12-29 06:16:10
问题 I am currently working with the Android Contacts content provider and currently can access a contacts full display name without issue using the following code: String[] PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER, }; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; String SELECTION = "LOWER(" + ContactsContract.Contacts.DISPLAY_NAME + ")" + " LIKE '" +