Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
tabenny
Posts: 6
Registered: ‎01-20-2009
Accepted Solution

Creating Contact using ContactList.createContact() and multiple Address lines

I have a situation where the Address contains 3 lines plus City,State and Zip, as following

 

Address 1
Address 2
Address 3
City,
State
Zip

 

When we use the code to create contact
ContactList contactList = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
Contact _contact = contactList.createContact();
String[] addressArray =new  String[contactList.stringArraySize(Contact.ADDR)];
addressArray[Contact.ADDR_STREET] = "Address1"
addressArray[Contact.ADDR_EXTRA] = "Address 2"
addressArray[Contact.ADDR_LOCALITY] = "City"
addressArray[Contact.ADDR_REGION] = "State"
addressArray[Contact.ADDR_POSTALCODE = "Zip"

 

I could not find a way to include "Address 3"


What are the options available to include 3 lines in address where we have only "Contact.ADDR_STREET" in addressArray[Contact.ADDR_STREET] and also we can use addressArray[Contact.ADDR_EXTRA].


Please advise

Please use plain text.
Developer
jsdyer
Posts: 53
Registered: ‎10-02-2009
My Carrier: Verizon

Re: Creating Contact using ContactList.createContact() and multiple Address lines

There is no address 3.  You'd have to use either ADDR_EXTRA (Address2), FORMATTED_ADDR, or USER 1-4 (user defined field) to create your own.

 

contact.addString(BlackBerryContact.ADDR...)

contact.addString(BlackBerryContact.ADDR_EXTRA...)

contact.addString(BlackBerryContact.FORMATTED_ADDR...)

 

With FORMATTED_ADDR, you can specify the entire address as one string.  So perhaps...

 

 

String ADDR1 = "Name";
String ADDR2 = "Company";
String ADDR3 = "Cube Number";
String STREET = "123 Fake St";
String CITY = "Fake City";
String STATE = "Philadelphia";
String ZIP = "19104";


String ADDRESS = ADDR1 + ", " + ADDR2 + ", " + ADDR3 + ", "...etc


contact.addString(BlackBerryContact.FORMATTED_ADDR, PIMItem.ATTR_NONE, ADDRESS);

 

 

 

Please use plain text.