Deploying a Database to Isolated Storage

As stated earlier in this chapter, a local database is read-only when it is located in a XAP file. If you want to provide a prepopulated database that is writable from your app, the database must be copied by your app, from your XAP file, to isolated storage.

Like any other resource, such as an image file, an .sdf database file may be stored as content within your app’s XAP file. The app then reads the database file as a Stream of bytes and writes the bytes to isolated storage. After the database has been copied to isolated storage, it is ready to be used by your app.

Note

To prevent the size of your project’s assembly from being unnecessarily increased by the inclusion of a database file, set the file’s ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.