Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Windows Phone 7.5 Data Cookbook
Windows Phone 7.5 Data Cookbook

Windows Phone 7.5 Data Cookbook: Over 30 recipes for storing, managing, and manipulating data in Windows Phone 7.5 Mango applications.

eBook
$9.99 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Windows Phone 7.5 Data Cookbook

Chapter 2. Isolated Storage

In this chapter, we will cover:

  • Saving user settings

  • Opening a file

  • Creating a file

  • Saving username and password

  • Saving an image

Introduction


In Windows Phone 7 environment, local storage is the space available for each application. We can read and write data in this area, but we do not have access to other applications' storage areas or direct access file systems. Isolated storage is the virtual file system available within the application.

There are two main classes used; one is IsolatedStorageSettings class and other is IsolatedStorageFile class. Both classes are part of the namespace System.IO.IsolatedStorage.

IsolatedStorageSettings uses the dictionary mechanism to store data, hence it uses a key and a value pair for storing any value. Some of the most commonly used methods are Add, Remove, and Contains.

The IsolatedStorageFile class uses isolated storage with files and directories. Therefore, you can save any file stream to the local storage using IsolatedStorageFileStream. Some of the common methods used for managing the files are FileExists, CreateFile, OpenFile, and DeleteFile. Similarly, DirectoryExists,...

Saving user settings


In our first recipe, we will introduce the namespace and the classes used in isolated storage and also learn how to save simple user settings to local storage and retrieve the user settings from the local storage.

Getting ready

  1. Open the Visual Studio for Phone 7 and create a Windows Phone Application. Name the application Ch2_Recipe1 and click on OK.

  2. After you open the project, press F5 and run it to make sure everything compiles without errors.

How to do it...

Let's build a simple page to display a textbox, where one can enter a name and store it so it automatically appears each time this app is started.

  1. Open the MainPage.xaml file and change the name of the application title and page title as follows:

    <!--TitlePanel contains the name of the application and pagetitle-->
    
    <StackPanel x:Name="TitlePanel" Grid.Row="0"  Grid.ColumnSpan="2">
      <TextBlock x:Name="ApplicationTitle" Text="MY RECIPES" Style="{StaticResource PhoneTextNormalStyle}"/>
      <TextBlock...

Opening and creating a file


In this recipe, we will learn how to open a file from local file storage and how to save the user settings to local file storage.

Getting ready

  1. Open Visual Studio for Phone 7 and create a Windows Phone Application. Name the application Ch2_Recipe2 and click on OK.

  2. After you open the project, just press F5 and run it to make sure you don't get any error.

How to do it...

Let's build a simple page with a textbox to enter text to save and a text block to display the saved text in the local file storage.

  1. Open the MainPage.xaml file and change the application title and page title to MY RECIPES and iFileStorage respectively:

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
      <TextBlock x:Name="ApplicationTitle" Text="MY RECIPES" Style="{StaticResource PhoneTextNormalStyle}"/>
      <TextBlock x:Name="PageTitle" Text="iFileStorage" Margin="9,-7,0,0" Style="{StaticResource...

Saving username and password to a local store


In this recipe we will learn how to save a username and password to local storage settings.

Getting ready

For this recipe let's copy the simple MyTasks app solution folder we built in Chapter 1, Data Binding to UI Elements, and rename the folder to Ch2_Recipe3_MyTasks. After you open the project, just press F5 and run it to make sure you don't get any errors.

How to do it...

Let's add another icon in the bottom navigation bar to link it to the Settings page. Then create the Settings page with the different controls to save the username and password.

  1. First, add another bar item at the bottom to navigate to user settings page, which we will be creating in step 3:

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
      <shell:ApplicationBar BackgroundColor="Orange" IsVisible="True" IsMenuEnabled="True">
    
        <shell:ApplicationBarIconButton IconUri="/Images/appbar.folder.rest.png" Click="ButtonFolder_Click...

Saving a background image to local storage


In this recipe we will learn how to save image files to a local storage folder. We will make use of the IsolatedStorageFile class.

Getting ready

For this recipe let's copy the simple MyTasks app solution folder we built in the previous recipe and rename the folder to Ch2_Recipe4_MyTasks. After you open the project, just press F5 and run it to make sure you don't get any errors.

How to do it...

Let's add a button control in the settings page to launch the built-in Photo Chooser utility. Once the desired photo is selected we will save the image to local storage.

  1. Open the settings .xaml file and add a text block control and button control inside the ContentPanel grid:

    <TextBlock Height="55" HorizontalAlignment="Left" Margin="12,199,0,0" Name="textBlock1" Text="Bacground Image" TextWrapping="Wrap" VerticalAlignment="Top" Width="115" />
    <Button Content="Browse" Height="77" Margin="119,0,70,331" Name="btnBrowse" VerticalAlignment="Bottom" Click="btnBrowse_Click...
Left arrow icon Right arrow icon

Key benefits

  • Simple data binding recipes to advanced recipes for building scalable applications
  • Techniques for managing application data in Windows Phone mango apps
  • On-device data storage, cloud storage and API interaction.

Description

Windows Phone 7.5 Mango contains support for apps written in Silverlight or XNA. These apps can store data on the device, and also load and manipulate data from "the cloud" and other web services.This Windows Phone 7.5 Data Cookbook has a range of recipes to help you apply data handling concepts. You will be able to apply the knowledge gained from these recipes to build your own apps effectively. This Windows Phone 7.5 Data Cookbook starts with data binding concepts at the UI layer and then shows different ways of saving data locally and externally in databases. The book ends with a look at the popular MVVM software design pattern. The recipes contained in this book will make you an expert in the areas of data access and storage.

Who is this book for?

This book is for developers who want to build data-driven apps, or a line of business applications using the Windows Phone platform. It is also useful for developers on other mobile platforms looking to convert their apps to Windows Phone 7.5 Mango. Basic understanding of C#, XAML and Silverlight is required.

What you will learn

  • Create data binding to user interface elements with any data source
  • Create and save user settings to local isolated storage for later consumption.
  • Explore different on device database options such as commercial Perst, open source SQLite and Microsoft’s SQL CE.
  • Create and consume simple web services and understand LINQ features.
  • Scale the applications and work with WCF web services.
  • Understand REST and call different social media services like Twitter and RSS Feeds.
  • Create and understand MVVM model.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 28, 2011
Length: 224 pages
Edition : 1st
Language : English
ISBN-13 : 9781849691239
Vendor :
Microsoft
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 28, 2011
Length: 224 pages
Edition : 1st
Language : English
ISBN-13 : 9781849691239
Vendor :
Microsoft
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 120.97
Windows Phone 7.5 Data Cookbook
$43.99
Windows Phone 7 Silverlight Cookbook
$54.99
Windows Phone 7.5: Building Location-aware Applications
$21.99
Total $ 120.97 Stars icon
Banner background image

Table of Contents

8 Chapters
Data Binding to UI Elements Chevron down icon Chevron up icon
Isolated Storage Chevron down icon Chevron up icon
XML as a Data Store Chevron down icon Chevron up icon
Using Open Data Chevron down icon Chevron up icon
Using On-Device Databases Chevron down icon Chevron up icon
Representational State Transfer—REST Chevron down icon Chevron up icon
Windows Communication Framework—WCF Chevron down icon Chevron up icon
Model View ViewModel Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(6 Ratings)
5 star 66.7%
4 star 16.7%
3 star 16.7%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Tamer Maher Dec 28, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I `ve recently read "Windows Phone 7.5 Data Cookbook" . The book covers different database related alternatives in a chapter to chapter basis. You can read what you want without having to read the book from cover to cover. Chapters discuss different topics without being dependent on each other's.The book mainly targets experienced Windows Phone developers. The book aims at boosting your mobile database development skills. If you are not familiar with programming C#.net, Silverlight and other necessary development skills , then, you have to check some extra books too for the basics. But if you have been writing some Windows Phone applications and had some hard times with the database stuff, then you are in the right place.The book uses the latest updates in Windows Phone 7.1 SDK that enable developers write applications for the latest version Windows Phone 7.5The book discusses new stuff like Twitter , Atom and RSS, and mobile specific database connections using JSON, also the conventional powerful SQLite. and SQLCE . LINQ to SQL and ADO.net.There are some examples using REST and WCF and the new Model View View Model (MVVM ).The book uses a simple coding style, straight and to the point, without confusing the reader with complex code that doesn't add a value. After having hands on every topic separately, at the end of each chapter, you have a sum-up sample app where you combine all the knowledge you gained in the chapter in one single app to see how things fit together in the big picture.The book also uses examples that can be implemented in the real world, so you learn fast, improve your skills, and you don't have to reinvent the wheel.Although the book is great in discussing the different data alternatives, it should have made a comparison between the different alternatives and discussing pros and cons of each using different case studies showing when to use each alternative rather than another.Overall: that is a really good book.
Amazon Verified review Amazon
Steve G Dec 29, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Having written a couple of WP7 applications I was looking for a book that was small, consist, and could take my applications to a whole new data centric level, and this is definitely what I found with Windows phone 7.5 Data Cookbook. I was also after a good reference guide. Don't let the 224 pages deceive you, each recipe in a chapter builds on the previous and each one provides a great example of what it's trying to teach you without getting too bogged down in "boiler plate code".As the synopsis says, I would highly recommend that the reader has some basic knowledge of c# and Silverlight before picking up this book as the book wastes very little time in explaining how to get up and running other than providing links to the required software download.At the end of each recipe the book clearly explains how each application works and also provides web links to msdn and other sites for additional learning. I thought this was a great idea as there is little point republishing what is already widely available on the internet and allows the reader to go off and develop their understand further if they so wish.One of the biggest things I liked about this book is the fact the author doesn't feel compelled to stick with just writing about windows Phone and gives the reader an understanding of numerous other technologies, including non-Microsoft products. For example Chapter 5 walks the reader through various different databases that can run on the phone from Microsoft examples to open source examples. Chapter 8 is dedicated to the MVVM pattern and the author gives the reader a good understanding of the MVVM Light framework and how to use it on the Windows Phone. Several chapters also make use of Linq and Entity framework, but they walk the reader through these subjects in a clear way that even if you haven't used the technologies before you will have a good understanding of what is going on.The book starts off with a great first chapter on data binding which is probably one of the single most important concepts of Silverlight/WP7 applications. The second chapter then dives into the various methods for storing user/application settings in the isolated storage. Chapters 3 to 7 include various different methods for pulling data down to the phone and querying it locally, from using XML files on remote servers to using OData and RESTful interfaces to WCF services and retrieval from SQL CE and SQL Lite databases. And finally Chapter 8 provides a brilliant walk through of using the MVVM pattern and then how existing open source frameworks such as MVVM Light can make the process quicker to develop.As each chapter covers a different subject area you can almost jump into a chapter and start reading and developing the examples from it. There is one exception to this and the author makes clever use of the Visual Studio templates to prevent the user having to constantly go back and develop the same piece of code over and over again. Having written the chapters with this approach, I can now easily reference parts of the book whilst writing my own applications.I would highly recommend this book to anyone starting out writing any Windows Phone application which is data centric. Read this book, it will not take very long, before writing any code!!
Amazon Verified review Amazon
ArchieCoder Dec 29, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The Windows Phone 7.5 Data Cookbook covers 99% ways to deal with data with Windows Phone programming. The book does not lose time about C# programming. It goes directly about using data on a Windows Phone.For a beginner, the book can be easily read from start to the end, because the complexity increases gradually. For an intermediate or an expert, you can just pick the topic that you are interested; this is the best thing on a "recipe" style book.Some people might say that 224 pages are not enough to go deep on all technologies, but I can't say it is not a problem because the book contains a lot of website links if you want to go further on a specific topic.The author succeeded to describe complex technology like incorporating SQL database in Windows Phone applications with the help of step-by-step images.From Isolated Storage to Windows Communication Framework, the book contains a lot of recipes that you can get new ideas for your next Windows Phone application!This book is the perfect reference guide for topics related with data.
Amazon Verified review Amazon
P. Pedireddi Dec 30, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I just bought this book. The book is written in such a way that developers with any experience level can easily grasp the contents. The chapters have been formatted very well. The example code provided is very helpful. This has lot of information. For this price of $40, it is definitely worth owning this book.
Amazon Verified review Amazon
Tim Dams Dec 09, 2011
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The basic premises of the book is the same as the other Packt `Cookbooks': each chapter consists of several step-by-step tutorials (dubbed "recipes") , each time resulting in a mini-program with full functionality.The main application that is rebuilt each time is a simple task manager. Each chapter 3 or more recipes are shown, usually (re)building the main task application. After each chapter and recipe a short explanation and reference to online sources is given .The book is aimed at developers who have little to no WP7 experience, however a solid Silverlight understanding is a must (for any WP7 developer that is) to get the most from this book. The 8 chapters are logically ordered, each time increasing in complexity. The first 3 chapters (databinding, isolatedstorage and XML) explain topics of which an abundant amount of online tutorials exist. They didn't really add much additional value for people already familiar with the basics of WP7. Though it should be pointed out that even the first recipes always did something `cool' or new in addition to the core topic: most tutorials stop once the basic idea is explained. In chapter 2, for example, an image file is read and subsequently the image is then used as a background image for the app. It's a small addition, but it lifts this (and other) recipe to a new, more usable, real-world example instead of a basic tutorial.Chapter 4 and further on the other hand is where the fun stuff starts: OData, WCF, REST services, on-device databases (SQL Lite, SQL CE) and even a MVVM-quicky all pass along.Though the book covers a lot of stuff, it only counts a meager 207 pages: compared to Gill Cleeren's Silverlight 4 Data Services Cookbook, the biggest `loss' of pages is due to the lack of additional information being given. Basically each recipes can be followed but once you want to find out why this or that step actually works the book can't help anymore. It's also a shame that only the first few pages of code have the most important parts highlighted in bold fonts. By highlighting this code, it easy to quickly see in a big pile of XAML what the essential part is (even more once the boiler-plate code starts becoming repetitive). For some reason, the author stopped doing that after chapter 1.To conclude; the concept of independent recipes makes it ideal to pick any chapter (or recipe) and start building stuff, without any dependencies on previous chapters or recipes. The downside however is that this also results in lots of identical steps that need to be taken each recipe. For me, this book is ideal in a classroom environment: students can be given a weekly recipe to solve and expand without the need of having made previous recipes.If the idea of this cookbook is to whet one's appetite of what can be done with the new 7.5 Mango Phone, it certainly succeeds . If on the other hand you expect in-depth explanation of one or more related topics, skip this one.You can find a more in-depth, per chapter review of this book here: [...]
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.