Exploring Networked Data and Data Stores Lesson 3
Exam Objective Matrix Skills/ConceptsMTA Exam Objectives Using Data StoresUsing data stores. (2.2) Working with Networked DataWorking with networked data. (2.1)
Data Stores Definition –A data repository or container that stores data Database Flat file (like a spreadsheet) Text file Data store items –Objects –May come from multiple sources
Example of a Text File as a Flat-File Repository
Different Types of Storage Files –Typical application files in Visual Studio IDE C# or Visual Basic (VB) XAML XAP Images –Content (preferred for optimization) –Resource (embedded in the project assembly)
Files for a Sample App Written in C#
Specifying the Content or Resource Build Action for a File
The Properties Window in Solution Explorer The Properties window appears below Solution Explorer by default Properties button
Different Types of Storage (continued) Databases –A collection of information organized for convenient access –Many are relational (linked to one another) –Database schema Defines the tables and fields, and the relationship between the two –Microsoft SQL Server
A Portion of Code from App.xaml.cs in the Local Database Sample
Describing Different Storage Locations Local –Read-only data stored within application Isolated –User-specific stored in special local containers Preferences, addresses, game scores Remote –On server located on the Internet
Local, Isolated, and Remote Storage in Windows Phone OS 7.1 Isolated storage Database Web service XAP Local file Mobile app Internet
Local Storage and Isolated Storage Local files (XML, Text, APIs) –May be compiled as content or resource files –Static (read-only) located within application –Dynamic files are located in isolated storage User-specific –Use Isolated storage to save data As key/value pairs In files and folders In a database
Remote Storage Data located on a server, accessed by Web services Web service –Proxy between a client (mobile app) and remote storage –Commonly used by mobile apps Windows Communication Foundation (WCF) WCF Data Services (OData services) Windows Azure Services
Accessing Native Data and Functionalities Launchers and Choosers (APIs) –Are called within an original application –Temporarily use built-in applications on device –Return the user to the original application Choosers –Can return data to the original application Launchers –Cannot return data to original application
A Portion of Code from ForecastPage.xaml.cs in the Weather Forecast Sample
Searching in the Code Sample Find in Files button Find All button
The Find Results Window
Camera Capture Code in a Sample File
Handling Offline Situations Occasionally connected application (OCA) –Synchronizes data on client device so information may be used while offline Retrieves data from remote server Stores data locally User can use app and data locally Synchronizes when connection is available
DB Accessing and synchronizing with remote database Mobile app Internet SQL Server DB Mobile app Internet SQL Server DB Working offline Data Synchronization and Offline Mode
Working with Networked Data Developers must determine –Which type of database engine to use –Where data will be located –How to access data –How to synchronize data –How to optimize app performance and bandwidth
A Portion of Code from MainPage.xaml.cs in the Network and Device Information Sample
Integrating with Databases Windows Phone 7.1 works with: –Microsoft SQL Server –SQLite –Microsoft SQL Server Compact Edition (SQL CE) Support local databases –Windows Phone 7.1 SDK Includes support for LINQ to SQL –Performs all local SQL-related database tasks –Filters and orders data within database layer
Synchronizing and Replicating Data Keeps information up to date on both a server and a mobile device Accomplished through: –Sync Framework Formerly Sync Services for ADO.NET Can exchange data supported by MSF –SQL Server replication Copies and maintains exact copy of data Merge replication used for mobile apps
Implementing Data Binding Data binding is a process creating a relationship between a data source and a control (target). –Connects UI to the data displayed –Enables user to modify and save changes Silverlight app data can be bound through: –XAML –C# –VB code
A Portion of Code from MainPage.xaml.cs in the Contacts and Calendar Sample App
Minimizing Data Traffic Develop app to be contained on the mobile device whenever possible –Three-tier approach Uses a server to check credentials and control bandwidth –Improves app and device performance Limits connection time with remote servers –Reduces bandwidth usage and user’s time spent accessing information
Windows Communication Foundation (WCF) Works with Representational State Transfer Protocol (REST) –Exposes resources on the Web that clients can access and use Example: Bing search engine Advantages: –Speed –Safety/security –Supports multiple bindings (including HTTP)
Recap Storage Local data Offline data Networked data Data stores Minimizing data traffic