|
 |
 |
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
- Download the file
- In the IDE, open the music_stores.jdw workspace
- Open the MusicStores.java source file.
Tasks
- In the static initializer, retrieve a reference to a PersistentObject using the store variable.
- In the synchronized block, if the PersistentObject is empty, set its contents to a new Vector.
- Retrieve PersistentObject contents and store it in a Vector.
TIP: Use the _data variable already defined.
- Add code to the StoreInfo inner class to define an object that can persist. TIP: Each object stores information about one music store.
- Add code to saveItem to create a Save menu item that saves the music store information that users have entered.
- 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
|
|
|
|