As we discussed earlier, there are several different ways that you might want to move data around during a synchronization. Let’s look at what is involved in moving data from the desktop to the handheld. This is commonly done with databases that are exclusively updated on the desktop and are routinely downloaded to handhelds where they aren’t modified. Or you may do this in the case that the user chooses “Desktop overwrites handheld” in the HotSync settings dialog (see Figure 11.3).
You need to create the database if it doesn’t yet exist. You should also delete any existing records before downloading the ones from the desktop. This is necessary because you don’t want the old ones; all you want are the newly downloaded ones.
There are a few different routines to choose from for deleting records:
Deletes one specific record
Deletes all records
Deletes all records from the specified category
Deletes all records that have been marked as deleted or archived
In our particular case, SyncPurgeAllRecs is the call we want to use.
Once you have a nice, empty database, you can fill it up with fresh records from the desktop. You do this with the Sync Manager call SyncWriteRec.
SyncWriteRec (CRawRecordInfo &rInfo)
rInfo (of class
CRawRecordInfo) contains several important fields:
Handle to the open database.