//mobile and embedded /
Wirelessly Back Up Your
Device’s Address Book
Learn to create a MIDlet to schedule a backup of your address book—and more.
VIKRAM GOYAL
JAVA IN ACTION
Java ME applications are notori- ously hard to back up. In this
article, I will go through the pro-
cess of creating a MIDlet applica-
tion that will allow you to select a
destination within your Bluetooth
network, create a schedule to back
up your address book, perform an
on-demand backup, and log (and
view) all of this activity. You can,
in addition, use this MIDlet to
extend backup activities to cover
other data that your device allows
you to access.
The Application Flow
Figure 1 shows the target application in action.
The application flow is divided
among the four options, which
represent logical activities. You
can look for destinations within
the device’s Bluetooth environment, create and edit a schedule to control when the backup
should be run automatically,
perform an on-demand backup,
and view the log.
Under normal circumstances,
you would create a schedule, set
up the destination once, and then
not worry about anything else. In
reality, only a signed application
with the proper permissions would
be able to do these things, because
you would need to grant the appli-
cation permission to read data and
initiate transfers (both
on the device and on
the target platform).
The basic code from
that previous article
hasn’t changed much
because the process
of sending the data is
pretty much the same.
What is different is
that we need to search
for a Bluetooth con-
nection point, find the
To do so, we create a RecordStore
and hold this connection point
(the actual connection URL) in
that database. This RecordStore
is called the Backup Store in the
code in Listing 1, and it is initiated
when the MIDlet starts.
If this destination is not set,
any attempt to create a backup
will result in a simple message
stating that a backup destination
is not set.
The actual backup destination is set after the discovery of
You can, in
addition, use this
MIDlet to extend
backup activities to
cover other data that
your device allows
you to access.
Looking for
Destinations
I initiated the development of this MIDlet
with the intention of
using Wi-Fi to detect devices.
However, even though the File
Transfer API (JSR 75) supports the
discoverability and manipulation of folders on remote devices,
none of the implementation APIs
(including Oracle’s) supports
this. I used Bluetooth instead to
discover devices and the services
they allowed.
I described the Bluetooth discovery process and how we can
use it to send files over the network in a previous article, but I will
cover the main points again here.
ABOUT US
PHOTOGRAPH BY
JONATHAN WOOD/
GETTY IMAGES
blog