What if the handheld doesn't have enough memory to store a complete set of all of the data objects? Well, then we should check, which objects are to be replicated:
01public static void replicatePilots(){ 02
ObjectContainer desktop=Db4o.openFile(DTFILENAME); 03
ObjectContainer handheld=Db4o.openFile(HHFILENAME); 04
ReplicationSession replication = Replication.begin(handheld, desktop); 05
ObjectSet changed = replication.providerB().objectsChangedSinceLastReplication(); 06
07
/* Iterate through the changed objects, 08
* check if the name starts with "S" and replicate only those items 09
*/ 10
while (changed.hasNext()) { 11
if (changed instanceof Pilot) { 12
if (((Pilot)changed).getName().startsWith("S")){ 13
replication.replicate(changed.next()); 14
} 15
} 16
} 17
18
replication.commit(); 19
}
Now, only Pilots whose name starts with "S" will be replicated to the handheld database.