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.

Arrow left icon
Profile Icon Ramesh Thalli
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Oct 2011 224 pages 1st Edition
eBook
$9.99 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Ramesh Thalli
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (6 Ratings)
Paperback Oct 2011 224 pages 1st Edition
eBook
$9.99 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781849691222
Vendor :
Microsoft
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 28, 2011
Length: 224 pages
Edition : 1st
Language : English
ISBN-13 : 9781849691222
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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.