Help Center
Local Navigation
- Creating user interfaces
- Storing data
- Creating connections
- Managing applications
- Using custom messages and folders in the message list
- Applications for push content
- Localizing BlackBerry device applications
- Controlling access to APIs and application data
- Testing a BlackBerry device application
- Packaging and distributing a BlackBerry Java Application
- Glossary
- Provide feedback
- Legal notice
BlackBerry Manuals & Help
>
Documentation for Developers
>
Java Development Guides and API Reference
>
Development Guide - BlackBerry Java Development Environment - 4.7.0
Retrieve a collection from persistent storage
- Import the following classes:
- Import the net.rim.device.api.synchronization.SyncCollection interface.
- To provide the BlackBerry® device application with access to the newest SyncCollection data from the PersistentStore, invoke the PersistentStore.getPersistentObject() method using the ID of the SyncCollection.
private PersistentObject _persist; private Vector _contacts; private static final long PERSISTENT_KEY = 0x266babf899b20b56L; _persist = PersistentStore.getPersistentObject( PERSISTENT_KEY );
- Store the returned data in a vector object. _contacts = (Vector)_persist.getContents();
- Create a method to provide the BlackBerry device application
with the newest SyncCollection data before a wireless data backup session begins.
public void beginTransaction() { _persist = PersistentStore.getPersistentObject(PERSISTENT_KEY); _contacts = (Vector)_persist.getContents(); } - Create code to manage the case where the SyncCollection you retrieve from the PersistentStore is empty.
if( _contacts == null ) { _contacts = new Vector(); _persist.setContents( _contacts ); _persist.commit(); }
Parent topic: Collections