files and storage in windows phone 8

Upload: kieu-phat

Post on 02-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Files and Storage in Windows Phone 8

    1/10

    M4: Files and Storage in

    Windows Phone 8

  • 8/10/2019 Files and Storage in Windows Phone 8

    2/10

  • 8/10/2019 Files and Storage in Windows Phone 8

    3/10

    Target Agenda | Day 2

    Module and Topic | 10-minute breaks after each session / 60-minute meal break

    10 - App to App Communication 11 - Network Communication on Windows Phone 8

    12 - Proximity Sensors and Bluetooth

    13 - Speech Input on Windows Phone 8

    14 - Maps and Location on Windows Phone 8

    15 - Wallet Support

    16 - In App Purchasing

    Meal Break | 60-minutes

    17 - The Windows Phone Store

    18 - Enterprise Applications in Windows Phone 8: Architecture and Publishing

    19 - Windows 8 and Windows Phone 8 Cross Platform Development

    20 Mobile Web

  • 8/10/2019 Files and Storage in Windows Phone 8

    4/10

    WP7.1IsolatedStorage and IsolatedStorageSettings APIs

    Local Storage and Isolated Storage

    Windows.Storage (Windows Phone Runtime) programming

    Special Folders

    Shared/Media Shared/ShellContent

    Shared/Transfers

    Exploring the local folder with ISET

    Using Removable SD cards

    Module Agenda

  • 8/10/2019 Files and Storage in Windows Phone 8

    5/10

    Not Covered in this Module

    Local Database

    No change from WP 7.1 See these Jump Start modules:

    http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-St

    Application-Data-Storage-on-Windows-Phone--Part-1

    http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-St

    Application-Data-Storage-on-Windows-Phone-Part-2 SQLite database (native only)

    http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08b-Application-Data-Storage-on-Windows-Phone-Part-2http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-08a-Application-Data-Storage-on-Windows-Phone--Part-1
  • 8/10/2019 Files and Storage in Windows Phone 8

    6/10

    Persistent Storage in

    Windows Phone 8

  • 8/10/2019 Files and Storage in Windows Phone 8

    7/10

    Local Data Storage: Overview

    Package Manager installsall app files into the

    Installation Folder Read-only access from app

    Read-only referencedatabase

    Apps store data in

    Local Folder

    Settings and properties inthe app dictionary

    Unstructured data inIsolated Storage files

    Structured data indatabase files

    ApplicationSettings File

    App

    PackageManager

    W

    WP8 StorageAPIs or

    WP7 IsolatedStorage APIs

    DB

    Database file

  • 8/10/2019 Files and Storage in Windows Phone 8

    8/10

    File Type/ APIInstallation

    FolderLocal Folder Example

    Local Database datacontext

    appdata:/ isostore:/MyDataContextdb =newMyDataCont

    ("isostore:/mydb.sdf")

    Files access usingWP7.1 IsolatedStorage API

    not supportedStorageFileandStorageFolderAPIs

    var isf =

    IsolatedStorageFile.GetUserStoreF

    File access using

    Windows.StorageAPI via URIs

    ms-appx:/// ms-appdata:///local/

    varfile = await

    Windows.StorageFile.GetFileFromApnewUri("ms-appdata:///local/AppC

    File access usingWindows.Storage APIvia StorageFolderreferences

    Windows.

    ApplicationModel.

    Package.Current.

    InstalledLocation

    Windows.Storage.

    ApplicationData.

    Current.

    LocalFolder

    varlocalFolder =

    Windows.Storage.ApplicationData.C

    Windows.Storage.StorageFilestora

    awaitlocalFolder.GetFileAsync("C

    Different Methods For Addressing Storage Location

  • 8/10/2019 Files and Storage in Windows Phone 8

    9/10

    Three ways of getting a reference to the same file:

    // WP7.1 IsolatedStorage APIsvarisf = IsolatedStorageFile.GetUserStoreForApplication();

    IsolatedStorageFileStream fs = newIsolatedStorageFileStream("CaptainsLog.store", FileMode.Open, i

    ...

    // WP8 Storage APIs using URI

    StorageFilestorageFile = awaitWindows.Storage.StorageFile.GetFileFromApplicationUriAsync(

    newUri("ms-appdata:///local/CaptainsLog.store "));

    ...

    // WP8 Storage APIs

    Windows.Storage.StorageFolderlocalFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

    Windows.Storage.StorageFilestorageFile = await localFolder.GetFileAsync("CaptainsLog.store");

    ...

    WP8 File Access Alternatives

  • 8/10/2019 Files and Storage in Windows Phone 8

    10/10

    Storing Data using WP7.1

    Isolated Storage APIs