Viewers: in countries Watching now:
Discover how to build professional apps that encompass the 17 major feature areas of Windows Phone, from XAML to multimedia to network access. In this course, author Michael Lehman details the standard hardware device configuration, teaches how to navigate the development environment, and explores the Windows Phone APIs. The course shows how to build sample applications while learning Windows Phone concepts and frameworks, including the Metro design language.
Continuing on with our work in persisting data to isolated storage, let's convert the Sonnets app from using a flat XML file into using the onboard SQL CE database. In order to get ready to do that work we're going to do something that I do all the time, and something probably you'll need to do, which is to take an existing running Windows Phone app and copy it--a.k.a. clone--it and change the name and make it a new app. There are number of steps involved, so let's go through them one by one, and then we can verify that we have the new app under the new name, properly running in the emulator before we start making changes.
Step number one is to open up the directory containing all of your source code files which probably still also contains a Bin directory and an obj directory. No matter what you do in changing all these source code files and rebuilding the solution, if you don't delete these two directories first, the emulator and the device are not going to load your code, so I'll delete those guys. Now we will go up one level, and we'll open up the solution and start the renaming process.
If we look in the code we'll see that we have a namespace of SonnetsPlusFlatFile. If we look in the WMAppManifest, we'll see we have Sonnets+FF and number of other changes that we need to make. So let's go to the Edit menu and select Find and Replace and select Replace in Files, and let's find SonnetsPlusFlatFile and replace it with SonnetsPlusDB, and be sure to open the Find options and select Look at these file types, and make sure you have *.* selected.
That way it will find all the instances of SonnetsPlusFlatFile. We'll do the Replace, and you should get 17 occurrences replaced if you're following along with the end of the code from the last movie. Now we can close this Find and Replace, that's part of it. Let's next rename the project SonnetsPlusDB, and let's rename the Solution, again to SonnetsPlusDB, and then let's open up Project Properties.
Here we're going to find a number of things that still say SonnetsPlusFlatFile, because Find and Replace can't find and replace inside here. So again, we'll change this to DB, and this to DB, and you will notice the Startup object is no longer selected, but if we click on this, here is the SonnetsPlusDBApp, which is the one we want. And let's also change the name of the Xap file, SonnetsPlusDB and then change the Title to Sonnets+DB and the title token for the Tile, once again to Sonnets+DB, and let's take a quick look inside Assembly Information.
Our Search and Replace got that, since that was in the assembly info.cs. So now we can save and close this, and we need to go take one more look at WMAppManifest, and let's make sure that that's in a state where we can see all the properties. So you see we've already changed because of the Project Properties dialog, here Sonnets+DB and here is Sonnets+DB. But let's also go ahead and change the Author to SonnetsPlusDB author and the Publisher to SonnetsPlusDB.
And finally, there's one more crucial thing that we have to do, and that is we have to change this ProductID GUID. Because if you have the ProductID GUID as we used for Sonnets+FF, the emulator or device will not even load the app on the device. So we'll delete that, and now we need to generate a GUID. So we have got two options to do that. If we look at our Windows Explorer here, the Windows 7 SDK includes a tool you're probably familiar with called guidgen. That's what we're going to use.
Go ahead and run that and select Registry Format, select New GUID and Copy, and then we'll go back to Visual Studio and paste it in. If you don't have guidgen, which is found in the Program Files Microsoft SDKs Windows v7.0A Bin directory. You could also go to the Windows Phone Marketplace, and as we can see here--at least at the time of our recording--there were five free applications that will also generate your GUID.
All right! That's all that we need to do in order to be able to clone a Windows Phone App. Now since we're also cloning Sonnets+SF into Sonnets+DB, we want to make one more change, and that's in the string in the About box, down here where we have the emailTask.Subject, so let's change that to DB also. And now let us just say a sure to wish to the clone gods, and we'll press F5.
This is what happens when we screw something up. When we have an app that has all of the things that are supposed to be changed, changed it just runs. In our case, we clearly missed something, so the way you know that it misses something is that it actually can't find the current app in order to change the IdleDetectionMode. So let's stop and take a look and figure out what we missed and then fix that up. So our first thing to do is once again try to delete the Bin and obj directories and see if that fixes it.
So let's go back to Windows Explorer, once again, we'll delete the Bin and obj directories, and we'll close this, and we'll give it another try. All right, we didn't stop there. The Emulator saying Hello, woo-hoo! We have now successfully renamed our app and cloned it, and we can prove that by coming back here and seeing there's a Sonnets+DB in the Application list.
We are going to have to remember to change the icon there so we can visually differentiate the two of them. We've now successfully cloned SonnetsPlusFlatFile into Sonnets+DB. So we're ready to move on and start looking at actually these onboard SQL CE database to read and write our data.
Find answers to the most frequently asked questions about Windows Phone SDK Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.