The first task for the MEP client code is to create the objects needed for synchronization and data manipulation:
A SyncManager object
A BusinessObjectStorage object
Optionally, a DefaultSecurityManager object or another extension of the SecurityManager class
You may also want to enable logging for debugging purposes by calling the SyncManager.enableLogging method. If logging is enabled, logging messages for the client code are written both to standard output and to a file on the device named meplog.txt.
You commonly perform these operations within a thread, as follows:
Thread t = new Thread(new Runnable() { public void run() { securityMgr = new DefaultSecurityManager("musicdb"); securityMgr.setMaxValidationAttempts(3); syncMgr = new SyncManager(".alb", securityMgr); syncMgr.enableLogging(true); boStorage = syncMgr.getBusinessObjectStorage(); } }); t.run();
This code first instantiates a security manager and sets the maximum allowed number of validation attempts. If this maximum is exceeded, all MEP records on the device are erased. See Data Destruction for details.
The code then uses the form of the SyncManager constructor that takes two arguments, the file extension used for the business object and the security manager. In this case, the extension is the string ".alb", as specified by the getExtension method of the Album class. The code also turns on logging.
Once you enable security by specifying an implementation of SecurityManager in the SyncManager constructor, all of the data stored locally on the device will be encrypted and decrypted automatically. There are no further requirements on the client application to explicitly perform encryption or decryption of the data.
The code then calls the SyncManager.getBusinessObjectStorage factory method to instantiate the BusinessObjectStorage object. This object provides storage for Album objects on the mobile device's file system.