Development Guide
Local Navigation
- Data storage overview
- Storing files in the file system
- Storing data in SQLite databases
- Storing objects persistently
- Storing objects nonpersistently
- Storing data in the record store
- Managing data
- Find more information
- Provide feedback
- Glossary
- Document revision history
- Legal notice
BlackBerry Manuals & Help
>
Developer Documentation
>
Java Development Guides and API Reference
>
Development Guide
Data Storage - BlackBerry Java SDK - 6.0
Store persistent data
- Import the required classes and interfaces.
import net.rim.device.api.system.PersistentObject; import net.rim.device.api.system.PersistentStore;
- Invoke setContents() on a PersistentObject. This method replaces the existing content with the new content.
- To save the new content to the persistent store, invoke commit().
String[] userinfo = {username, password}; synchronized(store) { store.setContents(userinfo); store.commit(); } - To use a batch transaction to commit objects to the persistent store, invoke PersistentStore.getSynchObject(). This method retrieves the persistent store monitor that locks the object.
- To commit a monitor object separately from a batch transaction, invoke forceCommit() while synchronizing the monitor object.
Next topic: Store an object in a batch transaction
Previous topic: Create a persistent data store