Advanced Java ME Programming

Advanced Java ME Programming

Wen-Chen Hu (University of North Dakota, USA)
DOI: 10.4018/978-1-59140-769-0.ch012
OnDemand PDF Download:
$37.50

Abstract

Chapter XI introduced the basics of Java ME programming. This chapter will build on this, focusing on advanced Java ME programming. The following two major topics will be discussed: • Persistent storage: This refers to the type of storage embedded in handheld devices. Random access memory loses its contents when the power is off, but the contents of persistent storage are preserved even when the power is off. Flash memory, and very occasionally hard disks, are usually used for this kind of storage. • Network connection: Many client-side applications such as weather reports and location-based applications require a network connection. The generic Connection framework of MIDP can be used for this purpose. Although these two chapters, Chapters XI and XII, introduce Java ME programming to readers, it is not possible to fully cover Java ME programming in only two chapters. For a deeper understanding, readers can consult the section on Java ME References provided later in this chapter for more information.
Chapter Preview
Top

Introduction

Chapter XI introduced the basics of Java ME programming. This chapter will build on this, focusing on advanced Java ME programming. The following two major topics will be discussed:

  • Persistent storage: This refers to the type of storage embedded in handheld devices. Random access memory loses its contents when the power is off, but the contents of persistent storage are preserved even when the power is off. Flash memory, and very occasionally hard disks, are usually used for this kind of storage.

  • Network connection: Many client-side applications such as weather reports and location-based applications require a network connection. The generic Connection framework of MIDP can be used for this purpose.

Although these two chapters, Chapters XI and XII, introduce Java ME programming to readers, it is not possible to fully cover Java ME programming in only two chapters. For a deeper understanding, readers can consult the section on Java ME References provided later in this chapter for more information.

Top

Persistent Storage

For some applications, including address books and appointment diaries, it is necessary for the information to be retained even after the application that created them is switched off.

Persistent (non-volatile) storage is a storage device whose contents are preserved when its power is off.

Without persistent storage, objects and their states are destroyed when an application closes. If objects are saved to persistent storage, their lifetime is longer than the program that created them and they can later be retrieved for users to continue to work with them. The MIDP Record Management System (RMS) is a persistent storage method for MIDlets. It is a simple record-oriented database, which consists of a collection of records. Record stores (binary files) are platform-dependent because they are created in platform-dependent locations, and MIDlets within a single application (a MIDlet suite) can create multiple record stores with different names. The RMS APIs provide the following functionality:

  • Allow MIDlets to manipulate records within a record store.

  • Allow MIDlets in the same application to share records.

They do not, however, provide a mechanism for sharing records between MIDlets in different applications. Record store names are case sensitive, and cannot be more than 32 characters long. Also, a MIDlet cannot create two record stores with the same name in the same application, although a record store can be created with the same name as a MIDlet in another application. When a new record store is created it is stored under a directory called appdb. For example, assume that you are using the Wireless Toolkit and that it is installed under the directory (C:\WTK23). If your record store is preferences, the record store is located at the address of the local disk: (C:\WTK23\appdb\DefaultColorPhone\run_by_class_storage_preferences.db).

Record Management System

The MIDP RMS implementation ensures that all individual record store operations are atomic, synchronous, and serialized, so no corruption occurs with multiple access. However, if MIDlets use multiple threads to access a record store, it is the programmer’s responsibility to synchronize this access. The RMS package consists of the following four interfaces, one class, and five exception classes:

  • Four interfaces:

    • ◯ RecordComparator: Defines a comparator that can be used to compare two records.

    • ◯ RecordEnumeration: Represents a bidirectional record enumerator.

    • ◯ RecordFilter: Defines a filter that can be used to examine a record and check if it matches based on criteria defined by the application.

    • ◯ RecordListener: Receives records which have been added, changed, or deleted from a record store.

  • One class:

    • ◯ RecordStore: Represents a record store.

  • Five exception classes:

    • ◯ InvalidRecordIDException: Indicates the RecordID is invalid.

    • ◯ RecordStoreException: Indicates a general exception has been thrown.

    • ◯ RecordStoreFullException: Indicates the record store file system is full.

    • ◯ RecordStoreNotFoundException: Indicates the record store could not be found.

    • ◯ RecordStoreNotOpenException: Indicates an operation on a closed record store.

Complete Chapter List

Search this Book:
Reset
Table of Contents
Preface
Wen-Chen Hu
Chapter 1
Wen-Chen Hu
With the introduction of the World Wide Web, electronic commerce revolutionized traditional commerce, boosting sales and facilitating exchanges of... Sample PDF
Fundamentals of Mobile Commerce Systems
$37.50
Chapter 2
Wen-Chen Hu
Commerce, the exchange or buying and selling of commodities on a large scale involving transportation of goods from place to place, benefits from... Sample PDF
Mobile Commerce Applications
$37.50
Chapter 3
Wen-Chen Hu
Mobile users interact with mobile commerce applications by using small wireless Internet-enabled devices, which come with several aliases such as... Sample PDF
Mobile Handheld Devices
$37.50
Chapter 4
Wen-Chen Hu
Without ways to conduct secure commercial information exchange and safe electronic financial transactions over mobile networks, neither service... Sample PDF
Essential Mobile-Commerce Technology
$37.50
Chapter 5
Wen-Chen Hu
As handheld computing is a fairly new computing area, there is as yet no generally accepted formal definition. For the purposes of this book... Sample PDF
Mobile World Wide Web Content
$37.50
Chapter 6
Wen-Chen Hu
Wireless application protocol (WAP) (Open Mobile Alliance, 2003) is a suite of network protocols that specifies ways of sending data across the... Sample PDF
WML (Wireless Markup Language)
$37.50
Chapter 7
Advanced WML  (pages 180-206)
Wen-Chen Hu
Chapter VI discusses the creation of static web pages, which have a fixed content at all times. In order to change static web pages to dynamic ones... Sample PDF
Advanced WML
$37.50
Chapter 8
WMLScript  (pages 207-228)
Wen-Chen Hu
WML is a markup language used for text formatting and displaying (Open Mobile Alliance, 2001). However, the functions of a markup language are... Sample PDF
WMLScript
$37.50
Chapter 9
Wen-Chen Hu
Numerous server-side handheld applications are available for devices. Some popular applications include: • Instant messages, which require service... Sample PDF
Database-Driven Mobile Web Content Construction
$37.50
Chapter 10
Wen-Chen Hu
There are two kinds of handheld computing and programming, namely client- and server- side handheld computing and programming. The most popular... Sample PDF
Client-Side Handheld Computing and Programming
$37.50
Chapter 11
Wen-Chen Hu
Most client-side handheld programming uses either Java or C/C++. This chapter introduces Java ME (previously known as J2ME), which is a version of... Sample PDF
Java ME (Java Platform, Micro Edition) Programming
$37.50
Chapter 12
Wen-Chen Hu
Chapter XI introduced the basics of Java ME programming. This chapter will build on this, focusing on advanced Java ME programming. The following... Sample PDF
Advanced Java ME Programming
$37.50
Chapter 13
Palm OS Programming  (pages 333-350)
Wen-Chen Hu
Programming for Palm devices is not a trivial task and it is especially hard for beginners starting their first assignment. This chapter is not... Sample PDF
Palm OS Programming
$37.50
Chapter 14
Wen-Chen Hu
The introduction to Palm OS programming given in the previous chapter provided an overview of its structure and basic concepts. This chapter... Sample PDF
Advanced Palm OS Programming
$37.50
The Resource Description Files: ResourceDescription1.xrd
About the Author