The latest release of HealthVault SDK has a sample called "OfflineAccess". We have been asked by some our partners about the details of doing an offline access to the HealthVault store, and this simple sample demonstrates it. The MSDN article Offline Access, talks a lot more about offline access; and a previous blog post HealthVault applications and offline access... elaborates on the usage scenarios.

In order to have offline access to datatypes of your interest you will have to request a separate application Id for it. Please note that the bar for offline access is higher, as the user must trust such an application a lot more. Typical scenarios in which such an access is granted to partner is - for doing a background data sync, avoiding mutiple authentication screens (one for HealthVault and one for their application), etx. No application is ever granted offline access to all data types for privacy and security reasons.

The offlineaccess sample application has offline access to only height data type. Its a very simple application which extends helloworld sample to show offline access.

When you run the offlineaccess application the default page will show a button "Get Height Records Offline" on clicking this button the application will give you a link to save the record for offline use or show you the data offline. If you are using the application for first time and click on the "save them here" link the application will have you log in and then present a page with a button "Add Height and Get Offline Access for it", clicking button adds a random height entry to your records and also saves PersonId and RecordGuid in a local file "offline.txt". This file is used by the default page to get the Person Id, RecordGuid to access the user height records offline.

In case the application throws an access error while creating the file "offline.txt", please make sure that your account has access to create files in local directory.

In the sample code the methods of interest for offline scenarios for you will be
1. Store records for offline use
void AddForOfflineUse(Guid personId, Guid recordId) in GoOffline.aspx.cs
2. Using saved records to create an offline connection
protected void OfflineData_Click(object sender, EventArgs e) in Default.aspx.cs

Hope this helps, Enjoy!