Choices for Persistence BLACKBERRY

The BlackBerry offers several ways to store persistent data on the device. In versions of the JDE prior to version 5.0, these are:

  • MIDP’s Record Management System (RMS)
  • lackBerry Persistent Store
  • SR 75 FileConnection support
  • DE Version 5.0 adds one more: SQLite.

Because this book is designed to help you develop for the widest range of BlackBerry devices, we’ll only briefly touch on SQLite, which is only available on devices with OS 5.0 or later.

RMS

RMS is supported by BlackBerry mostly as part of supporting the MIDP standard. It’s a simple, non-relational database format that enables the application to store arrays of bytes. There’s minimal support for sharing data between applications, and application data is attached to the application—that is, when the application is removed from the device, application data is also removed. Generally, there’s no reason to use RMS unless you’re supporting legacy code or developing a MIDlet instead of a BlackBerry CLDC application, which, as we discussed in Chapter 3, is not usually an ideal choice for BlackBerry development. You can find information about RMS in many places on the Web, and in the BlackBerry Javadocs. All the relevant classes are located in the javax.microedition.rms package. RMS stores can be written only to the internal flash memory of the device.

Persistent Store

The BlackBerry Persistent Store provides similar features to RMS; however, it offers an easier way to store a wider range of objects and the capability to directly store instances of classes that you define in your applications. It also optionally offers compression and security with little extra work from the application, so it is the method you should use for most of your data storage functionality in a majority of BlackBerry applications. The Persistent Store classes are located in net.rim.device.api.system: PersistentStore and PersistentObject (PersistentContent provides compression and encryption). Finally, persistent stores can be written only to the device’s internal flash memory.

Runtime Store

The Runtime Store is similar to the Persistent Store, but doesn’t persist across device resets. It’s mostly useful as a mechanism for applications to share information.

JSR 75 FileConnection

The FileConnection APIs are part of Java Specification Request (JSR) 75. JSR is part of the Java Community Process. The other part of JSR 75 includes Personal Information Management (PIM) APIs, which are also supported by the BlackBerry, but they are outside the scope of this chapter. The FileConnection APIs allow you to access the BlackBerry file system—both the device’s internal memory and any SD card that is currently plugged into the device. The file system is where the BlackBerry stores pictures, media, files that are downloaded through the browser, and any attachments saved from email, and it is generally accessible by all BlackBerry applications on the device. It’s a good place to store large files, such as pictures or documents, especially if the user might want to access them in some other way, such as through the BlackBerry Desktop Manager.

SQLite

SQLite is a full SQL database implementation.t’s powerful and useful for storing structured data, but because it’s available only for devices that run BlackBerry OS 5.0 or later, you should use it only if you need it and are willing to target a smaller segment of BlackBerry devices. The BlackBerry SQLite implementation enables you to create and access databases stored on the device’s internal memory and external SD cards. Your choices for persistence cover a wide enough range of functionality to meet almost any application’s need. Because the Persistent Store and the FileConnection APIs are the most commonly used and cover the persistence needs of almost all applications, we’ll focus on those throughout the remainder of this. We’ll also build a couple of applications to explore how the APIs function.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

BLACKBERRY Topics