The various data of the app in WP where

Source: Internet
Author: User

First, the theory

1. Where are the various data of the app in WP?

This is a good introduction to the problem. There are Installtionfolder, Knownfolder, SD Card ...

2. An app 's data storage Overview

Two major parts, InstallationFolder and app Data Folder

3, Windows.Storage.ApplicationData and windows.security. Credentials Brief introduction

With the use of Windows.Storage.ApplicationData, we can get 3 different WP folders and 2 settings to save the dictionary, C # operation as follows

Windows.Storage.StorageFolder roam = Windows.Storage.ApplicationData.Current.RoamingFolder; Windows.Storage.StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFolder temp = Windows.Storage.ApplicationData.Current.TemporaryFolder; Windows.Storage.ApplicationDataContainer localsettings =  Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer roamingsettings = Windows.Storage.ApplicationData.Current.RoamingSettings;   

Second, local Folder and local Setting

1, localsetting use, C # code as follows:

//Create a simple settinglocalsettings.values["Examplesetting"] ="Hello Windows";// Read data from a simple settingobject value = Localsettings.values[ "examplesetting" ];< Span style= "color: #0000ff;" >if (value = = null//< Span style= "color: #008000;" > No data}else{// Access data in Value} // Delete a simple settinglocalSettings.Values.Remove (  "examplesetting");   

2, Localfolder use, C # code as follows:

  PrivateAsyncvoid Writetexttolocalstoragefile (string filename,StringText) {var fold = Windows.Storage.ApplicationData.Current.LocalFolder;//Open Folder StorageFile file =Await fold. Createfileasync (filename, creationcollisionoption.replaceexisting);//Create a fileAwait Fileio.writetextasync (file, text);//Write content in a file private async Task <string> readtextfromlocalstorage (string filename) {var fold = Windows.storage.applicationdata.current.localfolder;//await fold. Getfileasync (filename); // Open the corresponding file string result = await fileio.readtextasync (file);  read the contents of the file return 

Note: Here the operation of the file is very simple, the steps are in the computer to manage the file steps are similar.

Iii. Roaming Setting and Roaming Folder

If a user installs your program on multiple devices, it's a good experience if all the devices can share the same settings information. And roaming data provides an application that can synchronize the methods and settings on multiple different physical devices. It is automatically stored in the user's OneDrive format as a folder and as a dictionary of settings. The size of Roaming data is limited to Applicationdata.roamingstoragequota (typically around 100k, but it does not occupy the space of your OneDrive). The synchronization process diagram is as follows:

The Roaming Setting and Roaming Folder operate in the same way as the local folder and local Setting, which are not described here. However, roaming data change events need to be monitored in different devices. The C # code is as follows:

Windows.Storage.ApplicationData.Current.DataChanged + = current_datachanged, .... Object args) {    // Refresh your settings ...}    

Synchronization of data occurs in the background.

Iv. ways to obtain files in several different ways

The various data of the app in WP where

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.