Winstore's Application Data

Source: Internet
Author: User

I. Introduction of APPLICATION Data

Applicaion data is equivalent to the registry of a desktop application, storing some user configuration information, such as runtime status, user preferences, and so on, when the application is uninstalled, it is deleted, so do not store important data.

  Applicaion data is not lost even after an app update, there is a version control.

Ii. Classification by use

    • Local data   is stored only on the current device.
    • roaming Roaming data installed by this user's app can be synchronized. Windows will automatically help you sync your data to Microsoft's cloud server, but it will limit the size. If the user does not use the data for 30 days (such as a program uninstall), it will be deleted by the server.
    • Temporary temporary data may be deleted by the system at any time.

Third, according to the storage mode classification

APP settings

    •   Used to save configuration data, the deepest 32 layers, unlimited number, can be saved locally and can roam.
    • AppSettings supports all WINRT data formats except binary, if the file is stored with binary data.
    • The system verifies only the data format and length, and does not verify that the data is correct.

Use the static property of Applicationdata.localsettings to get the configuration of the Applicationdatacontainer class type.

APP Files

    •  There are three system-customized folders under the root directory: local, roaming, temporary.
    • You can build your own folders, but not more than 32 levels, the same unlimited number.

use the static property of Applicationdata.localfolder to fetch files of the storagefolder type.

Iv. code Examples

Store Local Data

        Applicationdatacontainer localsettings = applicationdata.current.localsettings;//Store A handle to a single configuration        new  Applicationdatacompositevalue ();//Store multiple configuration handles        Storagefolder Localfolder = applicationdata.current.localfolder;/ /Store file   handle
localsettings.values["examplesetting"] = "Hello Windows";;       /Storage Single configuration composite["intval"] = 1;       composite["strval"] = "string"; localsettings.values["examplecompositesetting"] = composite;//stores multiple configurations

Establishing a configuration hierarchy

Applicationdatacontainer container = Localsettings.createcontainer (" examplecontainer "if (LocalSettings.Containers.ContainsKey ( "examplecontainer " "examplecontainer"]. Values[ "examplesetting  "] =  hello windows< Span style= "color: #800000;" > "            

  Read configuration 

  

Object value = localsettings.values["Examplesetting"];//A settingApplicationdatacompositevalue composite =(Applicationdatacompositevalue) localsettings.values["Examplecompositesetting"];if (composite = =Null){//No data}Else{// Access data in composite["Intval"] and composite["Strval"] }bool Hascontainer = LocalSettings.Containers.ContainsKey ( " Examplecontainer " BOOL hassetting = false; (Hascontainer) {hassetting = localsettings.containers[  "examplecontainer"]. Values.containskey ( "examplesetting "            

  Delete Configuration

LocalSettings.Values.Remove ( "examplesetting" Span style= "color: #000000;" >); //applicationdatacontainersettings.remove localsettings.values.remove ( " Examplecompositesetting " applicationdatacompositevalue.remove  Localsettings.deletecontainer ( "examplecontainer< Span style= "color: #800000;" > "); //applicationdatacontainer.deletecontainer    

Winstore's Application Data

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.