Showing posts with label local storage. Show all posts
Showing posts with label local storage. Show all posts

Monday, June 18, 2018

How do you store application data in a UWP project?

You can store and retrieve composite application data in a UWP project using the Windows Storage. Specifically you will be using the Windows.Storage.ApplicationDataCompositeValue sealed class shown in the Object Browser.


ObjBrowser.png

In this post a project is described where in a pair of values are stored in the Windows Storage's local folder and retrieved. The values are stored using a button click event of a button and retrieved into text boxes in the click event of a second button.
The MainPage.xaml for the project is as shown.



MainPageXaml.png

The code for storing and retrieving is shown in the MainPageXAMLCs. You first define the local settingss using the Windows.Storage.ApplicationDataContainer and the local folder. The composite values are set to the local settings.

The retrieving is by extracting the values in the local settings and reading it into a text box.
The result of running the application is shown here.


The code can be simplified as suggested by the hint shown here:




Saturday, January 27, 2018

How do you store data in Local Storage?

Local Storage is supported if you use HTML. First of all you should make sure that your browser supports Local Storage. Data is stored as NAME,VALUE pairs in local storage.

You can review this post.

Let us say you want to store the string "Hi, Good Morning". You need to create a NAME \ VALUE pair, your VALUE being "Hi, Good morning" and the NAME can be anything. In the present example the NAME is "Greetings".

All you need to do is create a web page (just HTML) shown here:

Greetings.png

When you browse this page on your local IIS Server (localhost), you will see the greeting: