O'Reilly logo

J2ME in a Nutshell by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Persistent Storage

Almost all MIDlets need to be able to save information so that it is retained between invocations. Examples of the types of information that might need to be stored include the following:

  • Data entered by the user, such as text typed into a memo pad application.

  • User configuration or preference information. For a mail application, this might be the name of the mail server to which outgoing mail should be sent or how frequently to poll for new incoming mail.

  • Values that the user recently entered or uses frequently. For an application that accesses the Internet, for example, it would be helpful to keep a history of recently used URLs that the user can use as a shortcut list.

A J2SE application typically stores state in local files that are quickly and easily accessible from the hard drive or transparently accessible over a fast local area network. Mobile devices, however, do not have local disks and rarely have network connectivity that is permanently available or fast enough to support storage of frequently used information at a remote location. The MIDP specification requires all implementations to provide a persistent storage facility so that information can be preserved while a MIDlet is not running or when the device is turned off. In practice, the actual storage mechanism may vary from device to device, but the programming interface does not, which makes MIDlets that use this facility more portable than if they had been required to be aware of the device-dependent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required