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("MyData.store"); 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("MyData.store"); 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.
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…