Windows Phone Runtime Storage

By | July 21, 2013

Windows Storage is an older technique which was also used in tradition windows application development, it uses a namespace Windows.Storage. Similar to Isolated Storage there is also a terminology used in Windows Storage:

  • StorageFolder – It represents the storage area containing files and folder.
  • StorageFile – Represents a file and provides method for manipulating them.

Now here you need to keep a note of one thing that traditional name value pair i.e. ApplicationData.LocalSettings is not supported in Windows Phone 8, for this you can either create a custom file or use IsolatedStorageSettings.

Saving Data

StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await localFolder.CreateFileAsync("");
Stream writeStream = await storageFile.OpenStreamForWriteAsync();
using (StreamWriter writer = new StreamWriter(writeStream))
await writer.WriteAsync(databox.Text);

Loading Data

private async string loadData()
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await storageFolder.GetFileAsync("");
Stream readStream = await storageFile.OpenStreamForReadAsync();
using (StreamReader reader = new StreamReader(readStream))
return await reader.ReadToEndAsync();

The code is as simple as it seems, lets have a quick demo on how it works.

One thought on “Windows Phone Runtime Storage

  1. Nokia DVLUP, a fun, collaborative, competitive environment to build Windows Phone apps!

    I recently came across a link to Nokia’s new developers program which goes by the name of DVLUP.. Have anybody else heard of it?
    It is pretty exciting reward program as one has to complete challenges and earn cool badges nd reward points… Much more like an interesting game nd we can share it on our fb profiles too…


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.