Java Reference
In-Depth Information
public void run() {
try {
PIM pim = PIM.getInstance();
ContactList contList = (ContactList)
pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
Enumeration contacts = contList.items();
while(contacts.hasMoreElements()) {
Contact c = (Contact) contacts.nextElement();
String [] nameValues = c.getStringArray( Contact.NAME, 0);
String firstName = nameValues[Contact.NAME_GIVEN];
String lastName = nameValues[Contact.NAME_FAMILY];
list.append(lastName + ", " + firstName, null);
}
}
catch(Exception ex) {}
}
}
The class in Listing 7-9 is simple, too—its run method simply iterates over each
Contact in the open ContactList , getting the first and last names of each item and
appending them to the List instance passed by the calling thread. The code expressly
catches exceptions but does nothing with the exceptions; a real-world application
would probably navigate to yet another Form to show an error.
Understanding the Role Code Signing and
Verification Can Play
As you might imagine, a rogue application can do some real damage using the interfaces
described in this chapter. While not all Java ME implementations open up access to the
entire file system and applications suites—device vendors are free to expose only a por-
tion of the file system, keeping protected files such as those representing system or
network access settings hidden from all Java ME applications—the file system space
accessible via the FCOP is typically shared among multiple Java ME applications as well
as potential system applications. A rogue application (either accidental or by design)
consuming file system space willy-nilly or deleting files or PIM records belonging to other
applications could cause no end of grief for a device user.
To help protect against this, most device manufacturers and carriers only support
access to the interfaces in JSR 75 within applications that have been signed in some
way (see the “Marketing and Selling Your Application” section in Chapter 1 and the
“Packaging and Executing CLDC/MIDP Applications” section in Chapter 3). Code
signing ensures that only those applications trusted by the operator (and by extension,
 
Search WWH ::




Custom Search