130 likes | 245 Views
This session focuses on effective strategies for handling user data file transfers in Windows Phone 7 (WP7) applications. It provides insights into utilizing Isolated Storage and the Download Queue functionality to manage downloads efficiently. The talk covers practical demonstrations, including downloading images and implementing background transfers with Mango support. It emphasizes best practices for managing user interactions and safeguarding app state during tombstoning. Engage in a dialogue about the evolving requirements in mobile data handling and optimize your WP7 app's file management capabilities.
E N D
Strategies for Transferring User Data Files in your WP7 Apps By Jay E. KimbleThe Dev Theologian http://jaykimble.net
Disclaimers About This Talk • Prescriptive session – not necessarily instructive (Emphasis is on Strategy) • I am growing, too • Let’s make this a dialog • The first 2 demos work in WP7 (& in 7.1) • The final is about Background Transfers (Mango only)
Background • For WP7.0, I built an app that relies on data files that are end-user supplied • This was not a problem for my WinMo app • I used • a personally created lib for DropBox (but there are numerous options available) • IsolatedStorage • A third party library to simplified WebRequests
IsolatedStorage • IsolatedStorage is • a special storage area on the phone • for data files created by your app • for data files downloaded by your app • For WP7 (and WP7.1) there is no other local storage option available
Demo 1: Getting our feet wet • Simple demo to download an image file (& display it) • We’ll use WebClient for this • We’ll store the resulting file in IsolatedStorage
Download Queues • A Download Queue let’s a user manage the process of which files are downloading • It also let’s them start/stop transfers • We need a few objects to do this: • FileItem containing name, uri, progress, etc. • Collection of FileItems to choose from • Collection of FileItemsthat are queued to download • Downloader Object
Demo2: Download Queue • Let’s look at an implementation of this
Background File Transfers (BgXfers) • Simplifies the mess of managing requests • Only really needs a URI • You do need to handle Tombstoning so your app can remember what was downloading between sessions • API is controlled via a single shares object which you add transfer requests to
Download Queue == BG Xfers Best Practice • By building the Download Queue we actually took care of all the recommended UI! • The only things missing from our UI is • A settings mechanism for the user to control when a transfer can happen • Can it happen on battery? • Can it happen on a Cell Data Connection
TombstoningSidenote • Tombstoning is the process where the OS tells your app • it will be shutting down to free up memory • an app must save off it’s state immediately • A separate set of events fire when an app is restored from tombstoning • With BgXfers you need to always save the state of the transfers when the app is shutting down normally or Tombstoning
Demo3: Background Transfers • This demo will create a new MangoDownloader which will BG Transfers (we can actually download up to 5 items at a time!)
BgXfers Caveats/Notes • It does not work with all Cloud Services • It doesn’t work with SugarSync’s public storage • HTTP/HTTPS only (no FTP.. yet..) • It will work with other HTTP verbs (post) • You can pass post variables and some headers via properties in the Transfer Object • Different types of connections have size limitations (be aware of this.. You aren’t downloading a 100mb file on a 3g connection!)
Resources • BG Xfers • See the docs on MSDN (especially the best practices • Fla-wimo-dev.groups.live.com • Joe’s wiki –dfwiki.devfish.net • Wp7dev.wikispaces.com