FMX.AddressBook.Types.TContactAddresses.AddAddress
Delphi
function AddAddress(const ALabel, ACountry, AState, ACity, AZIP, AStreet: string): TContactAddress; overload;
function AddAddress(const AKind: TContactAddress.TLabelKind; const ACountry, AState, ACity, AZIP, AStreet: string): TContactAddress; overload;
C++
TContactAddress* __fastcall AddAddress(const System::UnicodeString ALabel, const System::UnicodeString ACountry, const System::UnicodeString AState, const System::UnicodeString ACity, const System::UnicodeString AZIP, const System::UnicodeString AStreet)/* overload */;
TContactAddress* __fastcall AddAddress(const TContactAddress::TLabelKind AKind, const System::UnicodeString ACountry, const System::UnicodeString AState, const System::UnicodeString ACity, const System::UnicodeString AZIP, const System::UnicodeString AStreet)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | FMX.AddressBook.Types.pas FMX.AddressBook.Types.hpp |
FMX.AddressBook.Types | TContactAddresses |
Description
Adds a new address to a list of the contact addresses.
Use this method to add a new address to a list of the contact addresses. The input parameters of this method allows you to specify the following address-related characteristics:
Alabel
: in the first overloaded method, this parameters specifies an optional text label, such as "Home," " Office," etc.AKind
: in the second overloaded method, this parameters specifies the contact kind.ACountry
: specifies the country name.AState
: specifies the contact State, if any, such as California.ACity
: specifies the city name.AZip
: specifies the zip postal code.AStreet
: specifies the street, building number, office number or other similar information.
Examples
To clarify, consider the following examples. These code snippets illustrate how to specify the contact home address, and save this contact to Address Book.
Delphi:
var
Contact: TAddressBookContact;
Addresses : TContactAddresses;
begin
// Create an empty new contact in the default source
Contact := AddressBook1.CreateContact(AddressBook1.DefaultSource);
try
// Create an empty list of addresses
Addresses := TContactAddresses.Create;
try
// Add a home address to the list
Addresses.AddAddress(TContactAddress.TLabelKind.Home,'France',
'', 'Sceaux', '92330', '102-bis, rue Houdan');
// Add the address list to the contact
Contact.Addresses := Addresses;
finally
Addresses.Free;
end;
// Save the contact to Address Book
AddressBook1.SaveContact(Contact);
finally
Contact.Free;
end;
end;
C++Builder:
TAddressBookContact *contact;
TContactAddresses *addresses;
// Create a new contact in the default source
contact = AddressBook1->CreateContact(AddressBook1->DefaultSource());
__try{
// Create an empty list of addresses
addresses = new TContactAddresses();
__try {
// Add a home address to the list of addresses
addresses->AddAddress(TContactAddress::TLabelKind::Home, "France",
"", "Sceaux", "92330", "102-bis, rue Houdan");
contact->Addresses = addresses;
}
__finally {
addresses->Free();
}
AddressBook1->SaveContact(contact);
}
__finally {
contact->Free();
}
For more information and samples, see Mobile Tutorial: Using an Address Book Component (iOS and Android).