Troubleshooting guide
78
BlackBerry Java Development Environment Development Guide
Backing up and restoring data
Add support for backing up data over the wireless network
Task Steps
Set up the BlackBerry®
Enterprise Server to back up
the application data using
automatic wireless backup.
> Implement the OTASyncCapable and CollectionEventSource interfaces.
Activate the synchronization
process when the BlackBerry
device starts.
> In the main method, create code that activates the synchronization process.
public static void main(String[] args) {
boolean startup = false;
for (int i=0; i<args.length; ++i) {
if (args[i].startsWith("init")) {
startup = true;
}
}
if (startup) {
//enable application for synchronization on startup
SerialSyncManager.getInstance().enableSynchronization(new
RestaurantsSync());
} else {
RestaurantsSync app = new RestaurantsSync();
app.enterEventDispatcher();
}
}
The first time the BlackBerry device starts, the Alternate CLDC Application Entry Point project passes an
argument to the application so that the application registers only once.
Create a project that acts as
an alternate entry point to
the main application.
MIDlet applications do not support this task.
1. In the BlackBerry Integrated Development Environment, create a project.
2. Right-click the project, and then click Properties.
3. Click the Application tab.
4. In the Project type drop-down list, click Alternate CLDC Application Entry Point.
5. In the Alternate entry point for drop-down list, click the project that starts the synchronization process.
6. In the Arguments passed to field, type init. Make sure the value you type in the Arguments passed to field
matches the value in the startsWith argument in the main method of your application.
7. Select the Auto-run on startup option.
8. Select the System module option.
9. Click OK.
Provide an application with
schema data for a
SyncCollection.
> In your implementation of the OTASyncCapable interface, implement the getSchema()method.
public SyncCollectionSchema getSchema()
{// returns our schema
return _schema;
}