BlackBerry
Skip Top Navigation
Developers Partners
North America [change region] Products Solutions Purchasing Support
Developers


Storing Persistent Data

Exercise

Write an application that stores and uses persistent data.

Objectives

  • Discover how to store data for an application.
  • Discover how to create objects that can persist.
  • Discover how to save and retrieve data.

Setup

  1. Download the file
  2. In the IDE, open the music_stores.jdw workspace
  3. Open the MusicStores.java source file.

Tasks

  1. In the static initializer, retrieve a reference to a PersistentObject using the store variable.
  2. In the synchronized block, if the PersistentObject is empty, set its contents to a new Vector.
  3. Retrieve PersistentObject contents and store it in a Vector.
    TIP: Use the _data variable already defined.
  4. Add code to the StoreInfo inner class to define an object that can persist. TIP: Each object stores information about one music store.
  5. Add code to saveItem to create a Save menu item that saves the music store information that users have entered.
  6. Add code to getItem to create a Get menu item that retrieves and displays data from the last music store that was added.

Check Your Work

Download the completed code

Review

In this exercise, you discovered the following things:

  • how to create a data storage area for an application
  • how to create a new type of object that can persist
  • how to retrieve data from a persistent data store
  • how to add data to a persistent data store


Additional Labs

Go to the next exercise in “The Basics of Developing for BlackBerry”, Connecting to the network

Back to the Developer Lab Main Menu

 
Other Resources
 
     
 Home | Products | Solutions | Purchasing | Support | Developers | Worldwide | News | About Us | Contact Us | Site Map
 Legal | Copyright © 2008 Research In Motion Limited, unless otherwise noted.