Developers: Use SkyDrive to Backup App Data

One of the issues with Windows Phone is that you lose all your apps’ data when you upgrade to a new phone. However, developers can fix this by quickly implementing a backup/restore system via SkyDrive.

I realized that Windows Phone apps needed a backup solution, and so I added a simple SkyDrive backup system to my homework planner app, Power Planner. If you’re a developer, read the tutorial below to learn how to add the same system to your app!

 

Live Connect Account
First, you’ll have to setup a SkyDrive API account if you don’t have one. Go to the Live Connect site and login. It should prompt you to add your app’s details. Fill in your app name and language and click I Accept. Then go to the Application Settings Page, open the API Settings, and change the Mobile client app option to YES. Copy your Client ID number because you’ll need it later!

 

Live SDK
Now you need to download the Live SDK if you haven’t already. Go to Microsoft’s Download Page and download/install the MSI.

 

Adding References in your Project
Don’t forget to add the references to the Live SDK in your Visual Studio project! Add Microsoft.Live and Microsoft.Live.Controls to your references. Also, add System.Xml.Serialization (it’s used to serialize your data into a text file for uploading to SkyDrive).

 

Adding the Backup Page
Download my pre-existing backup page (click Save). After it is downloaded, right click the ZIP file and click the “Unblock” button to ensure the code files can be read. Then, unzip the file, and copy the two code files (xaml and xaml.cs) into your project.

Look through the xaml.cs page and change all the items that have “CHANGE” commented next to them. And then on the xaml page, change the namespace to your project and the ClientId number to your own.

 

Finishing it up
On your app’s settings page, make an entry for “backup” that opens the new backup page. Your settings page should be a separate page, not something on your panorama! And settings pages do NOT use pivot controls!

 

Final project sample
You can download a complete project sample here to see how everything works together. Also, you can download Power Planner in the Marketplace to see how this sample works with an app currently in the Marketplace.

12

About Andrew Bares

As an avid gamer, I see the Windows Phone as a solid platform for mobile gaming. I will review almost every WP7 game and give you an idea if it is worth your money or not! In addition to gaming, I have been using Windows Mobile since 2005, and understand just about everything there is to know about the Windows Phone platform. Xbox Gamertag: DirtSurfer07 (add me!)

  • Anonymous

    Is it possible to do this with XNA?

  • http://www.facebook.com/nizzon Johan Nilsson

    So now were going to rely on developers adding this to their apps? Yeah right that will happen..

    Microsoft need to fix this, not developers.

    • http://www.facebook.com/marsupy Paul Renda

      Not quite sure that’s going to happen… I agree Microsoft needs to fix this and quickly, as I want to upgrade to Nokia Lumia 900… :-)

      • http://www.facebook.com/nizzon Johan Nilsson

        Of course its not going to happen, I was being sarcastic.

    • Anonymous

      Regardless of whether or not Microsoft will do this (and I agree, there should be some native way to backup your phone), it’s still probably a good idea for app developers (depending on the app of course) to offer some sort of import/export routine for communicating with other services or allowing users to have a copy of their data away from the phone…the more backups the better I say.

  • http://www.facebook.com/ianlwold Ian Wold

    This is cool. Thanks for posting this, as a developer it gives me a head start to implementing SkyDrive.

    However, it would be great to see Microsoft automatically back up all the isolated storage so we don’t need to do this as developers.

  • Anonymous

    Thanks for the example. Sure beats the Microsoft examples that assume all we’ll want to backup is pictures :)

  • http://twitter.com/l0rdOdin Tishawn Fahie

    This is great! Thankyou Andrew!

  • Marco Engelke

    1. question: how to backup the isolatedStorageSettings instead of a file in isolated storage? 

    • http://www.facebook.com/profile.php?id=1300735256 Andrew Bares

      You would have to copy each of your isolated storage settings values into a List or some other data structure, and then upload it using this method. It may be possible to write code that would check through each value in IsoSettings, and upload them, but I haven’t tried that.

  • http://twitter.com/bookemdano Dan Francis

    Looks like this throws an exception for +2 UTC timezones when you call DateTimeOffset date = DateTime.MinValue; Changing to DateTimeOffset date = DateTimeOffset.MinValue; seems to work fine.

  • http://twitter.com/BrandonEtchison Brandon Etchison

    This 

Scan QR Codes, UPC, EAN, Code 39/128 or ITF barcodes on your Windows Phone 7 to find best prices online. Enjoy slots? Blackjack? Video Poker? Play Crazy Casino FREE! #1 FREE Solitaire on WP7 If your a fan of Pong then you will love this game. Heavenly Skies. Save the universe! Are you ready? A rewarding mix of match 3 and tetris gameplay Free, Live Tile support for Word Of The Day and so much more. Why NOT try it out? Set up reminders with only two taps. Supports also text reminders and voice reminders. Download the best puzzle game in WP7 Marketplace for FREE! Are you a good Alchemist ? Use your brain to discover Atomic Energy, Chuck Norris, Angry Birds and 1400 more ! Fun puzzle game with over 150 levels! Fully featured, beautifully designed WP7 YouTube app. u.n.i MEGA PACK (FREE), the ultimate addictive top GAMES bundle for Windows Phone 7! 7+ and growing! Highly addictive word game designed for adrenaline junkies. Practice locally, but then are you fast enough to compete online? Google RSS reader Windows Phone WP7 The smartest Google reader app. Air Soccer Tour Air Soccer Fever - Realtime Online Multiplayer casual soccer game for FREE Beat the Story Mode. When your done Bring your skill online. Rank up by winning online matches. Have 1 on 1's with anyone! Global Online Multiplayer! Newest devices leaks, online charts and ultimate performance benchmark for every Windows Phone. Every day, get great app deals from Windows Phone developers pushed to you! Quick Tiles, a fully featured live tile editor for Windows Phone. Great sports app for NFL, NBA, MLB, NHL. Pin scores/games to live tile on your home screen. MobileFax gives you the opportunity to send fax pages from your mobile phone anytime, anywhere ! WP7 Exclusive version of Hanging with Friends Fabulously fun, lovable, crazy! Bubble Pong Championship A remake of the classic snake game. The snake wants to grow so don't wait and help her!

Promote your app on WMPoweruser.com
Wholesale Cell Phones

Nokia LCD, Flex Cable,Wholesale phone partstrusted supplier.

Find the latest mobile phones at the cheapest prices at mobilephones.org.uk

Cell Phone Accessories

canon dslr cameras
See The Smartphone Database for the latest smartphone specs.

Windows Phone 7 Apps