I'm trying to add stuff to a list and export to csv, it works already but i want to export all the data i can get, so i added about 6 columns to the csv like:
B4X:
list1.Add (Array As String ("Name (or e-mail if name missing)","Home Phone", "Mobile phone", "E-mail (home)", "E-mail (work)","E-mail (Custom)", "Times contacted"))
and then below i go from 0 to listOfContacts.Size - 1
adding data to the list:
byt this is a map or something, contact data like myContact.PHONE_MOBILE only say "1" or "2" wich is the number of phones the user have. how do i add the number instead of 1 or 2.
i want to keep this simple
PHONE_xxx and EMAIL_xxx are constants with some integer values.
You should call Contact.GetPhones and get the Map object.
This Map holds pairs of phone numbers (keys) and their types (values). You can decide to pick the first item or to iterate over all items and find one with a specific type.
ok but i have a small problem here, if i add Contact.GetPhones(1) for example, and it is empty, the program crashes. i have to do a for cycle to get all those values and then add them to variables, affter that add them to the list, is that right?
if so, what is the FOR value limit? 2 or 3 ? (if starts at 0)
You should iterate over the available values.
For example if you prefer the HOME phone number you can use this code:
B4X:
Dim c As Contact
Dim phones As Map
Phones = c.GetPhones
Dim p As String 'Holds the result
p = "N/A"
For i = 0 To Phones.Size - 1
p = Phones.GetKeyAt(i)
If Phones.GetValueAt(i) = c.PHONE_HOME Then Exit
Next