Share via


ContactsContract.Contacts.ContentMultiVcardUri Property

Definition

Base Uri for referencing multiple Contacts entry, created by appending #LOOKUP_KEY using Uri#withAppendedPath(Uri, String).

[Android.Runtime.Register("CONTENT_MULTI_VCARD_URI")]
public static Android.Net.Uri? ContentMultiVcardUri { get; }
[<Android.Runtime.Register("CONTENT_MULTI_VCARD_URI")>]
static member ContentMultiVcardUri : Android.Net.Uri

Property Value

Uri
Attributes

Remarks

Base Uri for referencing multiple Contacts entry, created by appending #LOOKUP_KEY using Uri#withAppendedPath(Uri, String). The lookup keys have to be joined with the colon (":") separator, and the resulting string encoded.

Provides OpenableColumns columns when queried, or returns the referenced contact formatted as a vCard when opened through ContentResolver#openAssetFileDescriptor(Uri, String).

Usage example: <dl> <dt>The following code snippet creates a multi-vcard URI that references all the contacts in a user's database.</dt> <dd>

public Uri getAllContactsVcardUri() {
                Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
                    new String[] {Contacts.LOOKUP_KEY}, null, null, null);
                if (cursor == null) {
                    return null;
                }
                try {
                    StringBuilder uriListBuilder = new StringBuilder();
                    int index = 0;
                    while (cursor.moveToNext()) {
                        if (index != 0) uriListBuilder.append(':');
                        uriListBuilder.append(cursor.getString(0));
                        index++;
                    }
                    return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
                            Uri.encode(uriListBuilder.toString()));
                } finally {
                    cursor.close();
                }
            }

</p>

Java documentation for android.provider.ContactsContract.Contacts.CONTENT_MULTI_VCARD_URI.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to