Top Banner
All about data persistence in Windows 8 Andrei Marukovich [email protected] twitter: @amarukovich
20

All about data persistence in Windows 8

Apr 30, 2015

Download

Technology

Learn how to access and manipulate files on local and removable drives, how to roam settings between devices and how to store data in the cloud.

To learn more about Windows 8 data storage visit http://lunarfrog.com/blog/category/file-system/
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: All about data persistence in Windows 8

All about data persistence in Windows 8

Andrei [email protected]: @amarukovich

Page 2: All about data persistence in Windows 8

Windows Runtime

Win32 APIs

IE.NET

C# / VB

JavaScript C++

WPF

SL DXHTM

L

Desktop applications

Windows Runtime Services and APIs

Metadata

StorageSensor

s Media

UI XAMLControl

sNetwor

k…

IE EngineC++

.NET

JavaScript

C# / VB

HTML5Direct

XXAML

Windows Store apps

Page 3: All about data persistence in Windows 8

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

Page 4: All about data persistence in Windows 8

.NET Framework

Windows Store profile• Subset of client profile .NET framework• No File / FileInfo• No Directory / DirectoryInfo

Page 5: All about data persistence in Windows 8

File system entities

File system items• StorageFolder• StorageFile

Helper classes• PathIO• FileIO

Page 6: All about data persistence in Windows 8

Demo: Local data

• Windows.Storage.ApplicationData

• Folders

• Settings

• StorageFolder, StorageFile

• PathIO, FileIO

• ms-appx:///, ms-appdata:///local|temp|roaming/

Page 7: All about data persistence in Windows 8

Roaming

SkyDrive

RoamingFolderRoamingSettings

Page 8: All about data persistence in Windows 8

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;

Page 9: All about data persistence in Windows 8

Roaming

• Files

• Settings

DO

• Small data set synchronization between devices

DON’T

• Real-time communication

Page 10: All about data persistence in Windows 8

Libraries

Windows.Storage.KnownFolders• PicturesLibrary• MusicLibrary• VideosLibrary• DocumentsLibrary• HomeGroup• RemovableDevices

Page 11: All about data persistence in Windows 8

Demo: Libraries

• Libraries

• App Manifest

• Windows Property System

Page 12: All about data persistence in Windows 8

Demo: Pickers

• FolderPicker, FilePicker

• AccessCache

• Picker Contract

Page 13: All about data persistence in Windows 8

Files and settings

Application data• Local/Roaming folder and settings

User data• Libraries

Other folders and files• Pickers

Page 14: All about data persistence in Windows 8

Databases

Current state• No System.Data

Options• SQLite• ESENT• Azure Mobile Servces• Web/Cloud services of you choice

Page 15: All about data persistence in Windows 8

SQLite

using (var db = new SQLite.SQLiteConnection(dbPath))

{

db.CreateTable<City>();

db.RunInTransaction(() =>

{

db.Insert(new City() { Name = "Toronto" });

});

}

• SQLite for Windows Runtime extension• Managed SQLlite library, e.g. sqlite-net

Page 16: All about data persistence in Windows 8

ESENT

Extensible Storage Engine• Indexed sequential access data storage• Used by Windows 8 Zune Music and

Video

Managed wrapper• ManagedEsent.codeplex.com

Overviewhttp://lunarfrog.com/blog/2012/09/23/extensible-storage-engine/

Page 17: All about data persistence in Windows 8

Demo: Azure Mobile Services

https://manage.windowsazure.com/

Page 18: All about data persistence in Windows 8

App-to-app data sharing

Share Contract• Text• HTML• URI• Bitmap• File• Custom data • schema.org formats• https://

github.com/AndreiMarukovich/Transhipment

Page 19: All about data persistence in Windows 8

Data

Local storages• XML, SQLite, ESENT, etc.

Cloud storages• SkyDrive, Azure Mobile Services, custom

services

Page 20: All about data persistence in Windows 8

Thank you!

Andrei [email protected]: @amarukovich