contactscontract

All contacts that have more than one phone number

孤人 提交于 2019-12-24 21:12:25
问题 I'm trying to get all the contacts that have more than one phone number. Using sqlite3, I queried the database like this: select number,name,person,type from view_v1_phones where person in (select person from view_v1_phones group by person having count(*)>1); and got what I was looking for. However, I don't know how I can use this when I'm querying the database using contacts api (ContactsContract). Help! 回答1: Here is a link I found when I was working on something similar. This one is a

How to insert 'profile' contact programmatically in Android?

白昼怎懂夜的黑 提交于 2019-12-24 12:23:02
问题 I'm building an app that accesses a users 'Profile' contact on Android. However, there are some cases where the user may not have a 'Profile' contact set up. In this case, I would like to programatically insert the profile contact. However, I am unable to achieve this. Here is my code so far: ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newUpdate(ContactsContract.Profile.CONTENT

Update contact pictures - support other providers like outlook

▼魔方 西西 提交于 2019-12-24 07:26:34
问题 The code at the bottom shows how I update contact pictures from my app. This works well, if the user uses sim, phone and google contacts and similar. But if he uses the outlook app, the outlook app does overwrite the images set by my app again after some time. Can I somehow solve that? Can I force to overwrite the outlook image as well so that outlook syncs my new photo instead of their old one? Code byte[] photo = ImageUtil.convertImageToByteArray(bitmap, true); ContentValues values = new

ContactsContract select records by phone number

风格不统一 提交于 2019-12-24 07:16:02
问题 I can select all contacts using the query below cr = mActivity.getContentResolver(); String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " > 0"; String orderBy = ContactsContract.Contacts.DISPLAY_NAME + " ASC "; Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, selection, null, orderBy); However, I have a phone number list and I want to create this query like String selection = ContactsContract.Contacts.PhoneNumber_or_something_else in (MyPhoneNumberArray) Is that

querying contacts - SOMETIMES returns empty cursor

自古美人都是妖i 提交于 2019-12-23 12:16:17
问题 I'm trying to query contact's display name: @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQ_CODE_PICK_CONTACT: if (resultCode == Activity.RESULT_OK) { Uri contactUri = data.getData(); ContentResolver cr = getActivity().getContentResolver(); Cursor c = cr.query(contactUri, null, null, null, null); if (c != null && c.moveToFirst()) { //get the contact name } } break; } } Now here is the problem: For some contacts the cursor

Adding contacts using ContactsContract in batch

[亡魂溺海] 提交于 2019-12-23 03:21:56
问题 Can anyone please help me on adding new contacts in address book and apply them in batch by using new ContactsContract API? I could not find a proper tutorial on this. I am able to add a single contact. But batch update fails with Unknown contacts being added. Currently I am looping through while loop while collecting info. of users to write, store it in the ArrayList<ContentProviderOperation> and applying and ContentProviderResult[] result = getContentResolver().applyBatch(ContactsContract

How to set default image to Android phone contact that has no previous image

橙三吉。 提交于 2019-12-23 02:34:59
问题 I have a piece of code which updates the an Android contact´s image, the problem is that it doesn't work when the contact has no previous image. I also checked that the contact was from "Phone" account or "*@gmail.com" account. When it already has an image with these accounts I have no problem updating the image, the problem is just when the contact has no previous image assigned. Here is the method in charge of updating the image. public void update(long id, Bitmap bitmap) { ArrayList

Insert RawContact with a specific contactid

青春壹個敷衍的年華 提交于 2019-12-22 09:48:38
问题 I am trying to create a rawcontact in android that has a specific contact id, so it is linked to other rawcontacts with the same contactid (not rawcontactid). The problem is I am unable to insert the Contact_ID into the ContentProviderOpertations. Using the following code return "Insert failed" ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int id = (int) contactId; String condition = Data.RAW_CONTACT_ID + "=?"; String[] parameters = { "" + id }; try {

Android : Adding Notes to Existing Contacts

两盒软妹~` 提交于 2019-12-22 08:11:18
问题 I'm trying to use the ContactsContract api to add some notes to my contacts. I'm not sure I fully understand the various contact IDs and Raw Contact IDs. My problem seems pretty similar to what is discussed here. I want to : 1. Find a specific contact. 2. When found, insert specific notes I'm doing it in the following way: Cursor contacts = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, null, null, null); while(contacts.moveToNext()){ Log.d("TC", "Found : " + name); int

What does COLLATE LOCALIZED ASC stand for?

狂风中的少年 提交于 2019-12-21 03:12:07
问题 private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + (mShowInvisible ? "0" : "1") + "'"; String[] selectionArgs = null; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return managedQuery(uri, projection, selection, selectionArgs,