Help Center

Local Navigation

Store persistent data

  1. Import the following classes:
    • net.rim.device.api.system.PersistentStore
    • net.rim.device.api.system.PersistentObject
  2. Invoke setContents() on a PersistentObject. This method replaces existing content with the new content.
  3. To save the new content to the persistent store, invoke commit().
    String[] userinfo = {username, password};
    synchronized(store) {
    store.setContents(userinfo); 
    store.commit();
    }
  4. 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.
    1. Synchronize on the object.
    2. Invoke commit() as necessary. If any commit in the batch fails, the entire batch transaction fails.
  5. To commit a monitor object separately from a batch transaction, invoke forceCommit() while synchronizing the monitor object.

Index


Was this information helpful? Send us your comments.