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";
}