FMX.AddressBook.TCustomAddressBook.AllSources

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure AllSources(var ASources: TAddressBookSources);

C++

void __fastcall AllSources(TAddressBookSources* &ASources);

Properties

Type Visibility Source Unit Parent
procedure
function
public
FMX.AddressBook.pas
FMX.AddressBook.hpp
FMX.AddressBook TCustomAddressBook

Description

Gets a list of all sources in a device Address Book.

Use this method to get a list of all sources defined in the device Address Book. To get the default source, use the TAddressBook.DefaultSource method.

Examples

To clarify, consider the following examples. These code snippets illustrate how to fetch all sources defined in a device Address Book.

Note Before calling the AllSources method, you should explicitly initialize an instance of the ASources object using the TAdressBookSources.Create method (for Delphi) or new (for C++Builder).

Delphi:

// This onClick event handler displays a list of all sources defined in Address Book and the default source.
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  i: Integer;
  s: string;
begin
  AllSources := TAddressBookSources.Create;
  try
    AddressBook1.AllSources(AllSources);
    DefaultSource := AddressBook1.DefaultSource;
    try
      s := 'Available sources: ' + sLineBreak;
      for i := 0 to AllSources.Count - 1 do
        s := s + AllSources.Items[i].ID + ' / ' + AllSources.Items[i].SourceName
          + ' / ' + AllSources.Items[i].SourceType + sLineBreak;

      s := s + 'Default source: ' + DefaultSource.SourceName + ' / ' +
        DefaultSource.SourceType;
      Memo1.Text := s;
    finally
      DefaultSource.Free;
    end;
  finally
    AllSources.Free;
  end;
end;

C++Builder:

// This onClick event handler displays a list of all sources defined in Address Book and the default source.
void __fastcall TForm1::SpeedButton1Click(TObject *Sender) {
        TAddressBookSources *AllSources;
	int i;
	AllSources = new TAddressBookSources();
	__try {
		AddressBook1->AllSources(AllSources);
		TAddressBookSource *DefaultSource = AddressBook1->DefaultSource();
		__try {
			UnicodeString s = "Available sources: " + sLineBreak;
			for (i = 0; i < AllSources->Count; i++) {
				s = s + AllSources->Items[i]->ID + " | " +
					AllSources->Items[i]->SourceName + " | " +
					AllSources->Items[i]->SourceType + sLineBreak;
			}
			s = s + "Default source: " + DefaultSource->SourceName + " | " +
				DefaultSource->SourceType;
			Memo1->Text = s;
		}
		__finally {
			DefaultSource->Free();
		}
	}
	__finally {
		AllSources->Free();
	}
}



For more information and samples, see Mobile Tutorial: Using an Address Book Component (iOS and Android).

See Also