Java Reference
In-Depth Information
CHAPTER 7
Accessing Files and
Other Data
I n the last chapter, I showed you how to use the record store—the means of persistent
data that is common to all MIDP implementations. Sometimes, though, what you really
need is raw access to a file on the file system or access to data managed by integrated
applications such as built-in contacts managers or date topics. Not all devices support
this access; those that do implement JSR 75, which defines an optional interface for
accessing files on a local file system or personal information management (PIM) data
such as that kept by a contacts manager, date book, or to-do program. An implementa-
tion supporting JSR 75 may support file system access, PIM data, or both. Moreover,
although JSR 75 was developed originally for CLDC devices, it may be found on other
Java ME platforms as well. Given its flexibility and growing ubiquity, it's a good interface
for you to be familiar with.
In this chapter, I discuss both facets of JSR 75, so you can learn how to access both
files and PIM data. I begin with the File Connection Optional Package (FCOP), explaining
how it differs from the record store, and I show how it fits in with the Java GCF. Next, I
show you the actual APIs you use when interacting with the FCOP. After that, I turn your
attention to the PIM package, showing you how the classes in this package fit together to
give you an interface that works with the contacts, calendar, and to-do application on a
device. In conjunction with the previous chapter, this chapter gives you a firm grasp of
how to store data on MIDP devices.
Introducing the FCOP
JSR 75, introduced shortly after CLDC 1.0, solves a problem that hobbled many develop-
ers for J2ME, Java ME's immediate predecessor. Java applications were unable to safely
interact with integrated applications on a mobile device. The Java community (led by
Sun) introduced the PIM interface for specific applications managing PIM data. (I say
more about this later in this chapter, in the “Introducing the PIM Package” section.) But
for generic applications, or for those applications needing to manage their own files, the
FCOP provides the answer.
161
 
Search WWH ::




Custom Search