This example illustrates the basic code requirements for connecting to Unwired Server, updating mobile business object (MBO) data, and synchronizing the device application from a Client Object API based device application.
- Log in to Unwired Server using a user name and password:
<PkgName>DB.loginToSync("supAdmin", "s3pAdmin");
- Synchronize MBOs by group name synchronization:
<PkgName>DB.synchronize(“default”);
- Retrieve MBO data:
ObjectList customers = Customer.findAll();
int size = customers.count();
for (int i = 0; i < size; i++)
{
Customer cust = (Customer)customers.elementAt(i);
//Feed the MBO data to your view…
}
- Update MBO data:
Customer cust = Customer.findByPrimaryKey(100);
cust.setAddress(“1 Sybase Dr.”);
cust.setPhone(“9252360000”);
cust.save();//or cust.update();
- Submit pending operations and synchronize again:
Customer.submitPendingOperations();
<PkgName>DB.synchronize(“default”);