All about data
persistence in Windows
8

Andrei Marukovich
contact@lunarfrog.com
twitter: @amarukovich
Windows Runtime
      Desktop applications                 Windows Store apps

WPF       SL   HTML      DX     HTML5                XAML            DirectX

C# / VB    JavaScript          JavaScript       C# / VB
                         C++                                         C++
 .NET          IE              IE Engine            .NET

                               Windows Runtime Services and APIs
                                             Storage       Sensors   Media
           Win32 APIs
                                Metadata       UI          XAML      Controls

                                             Network         …
Windows Runtime
Sandboxed environment
• No direct communications between the apps
• Brokered access to system resources

File system direct access
• Local data
• Temporary data
• Installation folder
• Downloads
.NET Framework
Windows Store profile
• Subset of client profile .NET framework
• No File / FileInfo
• No Directory / DirectoryInfo
File system entities
File system items
• StorageFolder
• StorageFile

Helper classes
• PathIO
• FileIO
Demo: Local data
• Windows.Storage.ApplicationData
  • Folders
  • Settings

• StorageFolder, StorageFile
• PathIO, FileIO
• ms-appx:///, ms-appdata:///local|temp|roaming/
Roaming


RoamingFolder
RoamingSetting
s




                 SkyDrive
Roaming API
var roamingFolder = ApplicationData.Current.RoamingFolder;

StorageFile file = await roamingFolder.CreateFileAsync("dataFile.txt");

await FileIO.WriteTextAsync(file, “some text");



ulong quota = ApplicationData.RoamingStorageQuota;



ApplicationData.DataChanged += DataChangedHandler;
Roaming
• Files
• Settings

DO
• Small data set synchronization between
  devices
DON’T
• Real-time communication
Libraries
Windows.Storage.KnownFolders
• PicturesLibrary
• MusicLibrary
• VideosLibrary
• DocumentsLibrary
• HomeGroup
• RemovableDevices
Demo: Libraries
• Libraries
• App Manifest
• Windows Property System
Demo: Pickers
• FolderPicker, FilePicker
• AccessCache
• Picker Contract
Files and settings
Application data
• Local/Roaming folder and settings

User data
• Libraries

Other folders and files
• Pickers
Databases
Current state
• No System.Data

Options
• SQLite
• ESENT
• Azure Mobile Servces
• Web/Cloud services of you choice
SQLite
• SQLite for Windows Runtime extension
• Managed SQLlite library, e.g. sqlite-net

using (var db = new SQLite.SQLiteConnection(dbPath))
{
    db.CreateTable<City>();
    db.RunInTransaction(() =>
     {
           db.Insert(new City() { Name = "Toronto" });
     });
}
ESENT
Extensible Storage Engine
• Indexed sequential access data storage
• Used by Windows 8 Zune Music and Video

Managed wrapper
• ManagedEsent.codeplex.com

Overview
http://lunarfrog.com/blog/2012/09/23/extensible-storage-engine/
Demo: Azure Mobile Services
https://manage.windowsazure.com/
App-to-app data sharing
Share Contract
• Text
• HTML
• URI
• Bitmap
• File
• Custom data
  • schema.org formats
  • https://github.com/AndreiMarukovich/Transhipment
Data
Local storages
• XML, SQLite, ESENT, etc.

Cloud storages
• SkyDrive, Azure Mobile Services, custom
  services
Thank you!




Andrei Marukovich
contact@lunarfrog.com
twitter: @amarukovich
All about data persistence in Windows 8

All about data persistence in Windows 8