Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Instrukcja Naprawy Strona 80

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 286
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 79
80
BlackBerry Java Development Environment Development Guide
Access a SyncCollection
Task Steps
Retrieve an instance of the
SyncCollection from the
RunTimeStore.
> To make sure that the application works with only one version of the SyncCollection, implement a
static method that returns an instance of the
SyncCollection.
static OTABackupRestoreContactCollection getInstance()
{
RuntimeStore rs = RuntimeStore.getRuntimeStore();
synchronized( rs )
{
OTABackupRestoreContactCollection collection =
(OTABackupRestoreContactCollection)rs.get( AR_KEY );
if( collection == null )
{
collection = new OTABackupRestoreContactCollection();
rs.put( AR_KEY, collection );
}
return collection;
}
}
Retrieve the SyncCollection
from the PersistentStore.
1. To provide the application with access to the newest SyncCollection data from the
PersistentStore, invoke the PersistentStore.getPersistentObject() method using the ID
of the
SyncCollection.
2. Store the returned data in a vector object.
private PersistentObject _persist; // The persistable object for the
contacts.
private Vector _contacts; // The actual contacts.
private static final long PERSISTENT_KEY = 0x266babf899b20b56L;
_persist = PersistentStore.getPersistentObject( PERSISTENT_KEY );
_contacts = (Vector)_persist.getContents();
3. Create a method to provide the 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();
}
4. 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();
}
Przeglądanie stron 79
1 2 ... 75 76 77 78 79 80 81 82 83 84 85 ... 285 286

Komentarze do niniejszej Instrukcji

Brak uwag