Java Reference
In-Depth Information
public void verifyPIMSupport() throws IOException {
String version = "";
version = System.getProperty("microedition.pim.version");
if (version != null) {
if (!version.equals("1.0"))
throw new IOException("Package is not version 1.0.");
}
else
throw new IOException("PIM optional package is not available.");
}
private ContactList list = null;
private void seed() throws PIMException {
try {
PIM pim = PIM.getInstance();
list = (ContactList)
pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
}
catch (PIMException ex) { /* Contact list is not supported. */ }
addContact(list, "Ray", "Rischpater", "1234 High Street",
"Los Gatos", "USA", "95030");
addContact(list, "John", "Doe", "1111 Bear Road",
"Mariposa", "USA", "9????");
if (list != null)
list.close();
list = null;
}
private void addContact( ContactList list, String firstName,
String lastName, String street, String city,
String country, String postalcode)
throws PIMException {
Contact c = list.createContact();
String [] name = new String[list.stringArraySize(Contact.NAME)];
name[Contact.NAME_GIVEN] = firstName;
name[Contact.NAME_FAMILY] = lastName;
c.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
String [] addr = new String[list.stringArraySize(Contact.ADDR)];
addr[Contact.ADDR_STREET] = street;
addr[Contact.ADDR_LOCALITY] = city;
 
Search WWH ::




Custom Search