Introduction to Windows 8 style application Development 27 roaming application Data

Source: Internet
Author: User
Tags time interval

Overview of roaming Application Data

1. If the application uses the roaming application data, the user can easily keep the application data synchronized between different devices.

2.Windows synchronizes the updated roaming data to the cloud and updates the data to other devices that install the application.

3.Windows limits the size of the application data that can be roaming per application. If our application reaches the limit of roaming data size, no data will be updated to the cloud until the total roaming data applied is again less than the limit, so it is best to use roaming data only for user preferences, links, and small data files.

4. Whenever the user accesses the applied roaming data from a device within the required time interval, these data will exist in the cloud, if users do not run the application longer than this time interval, roaming data will be removed from the cloud, if users uninstall the application, roaming data will not automatically remove from the cloud, will be retained, If the user reinstalled the application during that time interval, the roaming data is synchronized from the cloud. Note: The time interval is specified as 30 days.

5.Windows random Roaming Application data, does not guarantee real-time synchronization. Roaming can be significantly delayed if the user is offline or is in a high latency network. For important time-critical settings, you can use a particularly high priority set unit to provide more frequent updates. It is limited to a specific set of units named "Highpriority". It can be complex, but the total size is limited to 8KB. This limit is not mandatory, and when this limit is exceeded, setting the unit or setting the complex will be treated as a regular setup unit or a composite body.

Second, how to build roaming application data

1. Registers the event that the roaming data has changed, this event is a datachanged event.

void Inithandlers ()   
       
{   
       
   Windows.Storage.ApplicationData.Current.DataChanged + =    
       
      new Typedeventhandler <applicationdata, object> (Datachangehandler);   
       
        
       
void Datachangehandler (Windows.Storage.ApplicationData AppData, object o)   
       
{   
       
   //update Data   
       
}

2. Get the application settings and file containers. Usually we use the Applicationdata.roamingsettings property to get the settings and Applicationdata.roamingfolder properties to get the file.

Windows.Storage.ApplicationDataContainer roamingsettings = Windows.Storage.ApplicationData.Current.RoamingSettings;   
       
Windows.Storage.ApplicationDataContainer roamingfolder = Windows.Storage.ApplicationData.Current.RoamingFolder;

3. Write data to Settings.

Use the Applicationdatacontainer.values property for simple data writing.

roamingsettings.values["examplesetting"] = "Hello World";

Use the Applicationdatacompositevalue object for composite settings.

Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue ();   
       
composite["Intval"] = 1;   
       
composite["Strval"] = "string";   
       
        
       
roamingsettings.values["examplecompositesetting"] = composite;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.