Click here to Skip to main content
15,441,434 members
Articles / Mobile Apps / Windows Mobile
Posted 19 Dec 2013

Tagged as


3 bookmarked

Isolated Storage in Windows Phone 8

Rate me:
Please Sign up or sign in to vote.
4.70/5 (6 votes)
19 Dec 2013CPOL
This tip shows you how to use the Isolated Storage in Windows Phone 8.


This tip shows you how to use the Isolated Storage in order to store and retrieve Application Settings like the name or the Identifier of the user of the current application.

Using the Code

Before we start coding, we must include System.IO.IsolatedStorage.

using System.IO.IsolatedStorage; 

Together, we will build an application where the user puts a number and a string.

<Grid x:Name="ContentPanel" Margin="24,133,0,28" Grid.RowSpan="2">
    <TextBlock HorizontalAlignment="Left" Margin="75,20,0,0" 
       TextWrapping="Wrap" VerticalAlignment="Top" 
        	<Run Text="Give  a number"/>
        	<Run Text=":"/>
    <TextBox x:Name="Entier" HorizontalAlignment="Left" Height="72" 
      Margin="63,52,-63,0" TextWrapping="Wrap" Text="" 
      VerticalAlignment="Top" Width="456"/>
    <TextBlock HorizontalAlignment="Left" Margin="75,155,0,0" 
      TextWrapping="Wrap" VerticalAlignment="Top">
        	<Run Text="Give a string"/>
        	<Run Text=": "/>
    <TextBox x:Name="chaine" HorizontalAlignment="Left" 
      Height="72" Margin="63,205,-63,0" TextWrapping="Wrap" 
      Text="" VerticalAlignment="Top" Width="456"/>

    <Button Content="save " HorizontalAlignment="Left" Margin="63,299,0,0" 
      VerticalAlignment="Top" Click="Button_Click_1" 
    <Button Content="put" HorizontalAlignment="Left" 
      Margin="234,299,0,0" VerticalAlignment="Top" Click="Button_Click_2"/>

Store Application Settings

If we want to store the number and the string entered by the user, we click upon a buton called "PUT" as shown in the following example:

private void Button_Click_2(object sender, RoutedEventArgs e)
    IsolatedStorageSettings isoStoreSettings = IsolatedStorageSettings.ApplicationSettings;
    int integerValue;
    int.TryParse(Entier.Text, out integerValue);
    //store the integer
    isoStoreSettings["IntegerValue"] = integerValue;
    //store the string
    isoStoreSettings["StringValue"] = chaine.Text;

Retrieve Application Settings

Now we want to retrieve the application settings, that is why we click upon the button "PUT"which has the following code:

private void Button_Click_1(object sender, RoutedEventArgs e)
    IsolatedStorageSettings isoStoreSettings = IsolatedStorageSettings.ApplicationSettings;
    int integerValue;
    string stringValue;
    //Retreive The integer
    if (isoStoreSettings.TryGetValue("IntegerValue", out integerValue))
        Entier.Text = integerValue.ToString();
    //Retreive the string
    if (isoStoreSettings.TryGetValue("StringValue", out stringValue))
        chaine.Text = stringValue;

Any comments are welcome.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Tunisia Tunisia
Microsoft Certified Professional, Big Data and Cloud Architect.
Mail :

Comments and Discussions

QuestionisoStoreSettings.Save(); not necessary. Pin
6T9Fan9-Jan-14 5:21
Member6T9Fan9-Jan-14 5:21 
AnswerRe: isoStoreSettings.Save(); not necessary. Pin
Hadrich Mohamed9-Jan-14 8:01
professionalHadrich Mohamed9-Jan-14 8:01 
Many thanks Smile | :) )

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.