Introduction to Windows 8 style application Development 26 local Application data

Source: Internet
Author: User

When an application is installed, the system provides its own per-user data store for application data such as settings and files. We don't need to know where or how to store the data because the system is responsible for managing the physical storage work. All we need to do is use the Application Data API.

Local application data is typically used for the persistence of current device data, and local data is not limited in size, and typically local data is used to store large datasets.

How to get the settings and file containers applied

1. Use the Applicationdata.localsettings property to get the settings in the Applicationdatacontainer object.

Windows.Storage.ApplicationDataContainer localsettings = Windows.Storage.ApplicationData.Current.LocalSettings;

2. Use the Applicationdata.localfolder property to get the files in the Storagefolder object.

Windows.Storage.ApplicationDataContainer localfolder = Windows.Storage.ApplicationData.Current.LocalFolder;

How to write data to Settings

We can write the data to the settings in three different ways.

1. Use the Applicationdatacontainer.values property.

localsettings.values["examplesetting"] = "Hello Windows";

How to use key-value pairs.

2. Use the Applicationdatacompositevalue object to make a composite setting.

Windows.Storage.ApplicationDataCompositeValue composite = new 

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

3. Use the Applicationdatacontainer.createcontainer method to create the settings container and add the data to the container.

Windows.Storage.ApplicationDataContainer container =    
       
   Localsettings.createcontainer ("Examplecontainer", 

Windows.Storage.ApplicationDataCreateDisposition.Always);   
       
        
       
if (LocalSettings.Containers.ContainsKey ("Examplecontainer"))   
       
{   
       
   localsettings.containers[ Examplecontainer "]. values["examplesetting"] = "Hello 

Windows";   
       
}

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.