19 out of 25 rated this helpful - Rate this topic

Isolated Storage Overview for Windows Phone

Windows Phone

March 23, 2012

Isolated storage enables managed applications to create and maintain local storage. Isolated storage in Windows Phone is similar to isolated storage in Silverlight. For a Windows Phone application, all I/O operations are restricted to isolated storage and do not have direct access to the underlying operating system file system or to the isolated storage of other applications. This improves security and reduces chances of unauthorized access and data corruption.

Depending on the type of data to be stored, Windows Phone applications can use isolated storage in the following ways:

  • Settings: Store data as key/value pairs by using the IsolatedStorageSettings class.

  • Files and folders: Store files and folders by using the IsolatedStorageFile class.

  • Relational data: Store relational data in a local database by using LINQ to SQL.

For examples that demonstrate how to use these features in your application, see How to: Create a Settings Page for Windows Phone, How to: Store Files and Folders for Windows Phone, and How to: Create a Basic Local Database Application for Windows Phone, respectively.

These options for general data storage are summarized in the following figure.

AP_Con_IStorage3

Tip Tip:

To synchronize access to isolated storage between different threads, we recommend using the System.Threading.Mutex class. A mutex grants exclusive access to a shared resource to only one thread. If one thread acquires a mutex, the second thread that wants to acquire that mutex is suspended until the first thread releases the mutex. For example, a mutex could be used to synchronize access to an isolated storage folder between a Windows Phone application running in the foreground and a background agent.

In addition to general data storage, isolated storage is used for the following special-use scenarios:

Path

Use

Notes

Shared

Used to host the Media, ShellContent, and Transfers folders.

This folder is created when your application is installed, but it can be deleted.

Shared/Media

Album Art: Applications can use this folder to display album art in the Universal Volume Control (UVC) while playing background audio.

This folder is created when your application is installed, but it can be deleted. For more information, see How to: Integrate with the Music and Videos Hub for Windows Phone.

Shared/ShellContent

Application Tiles: Tiles can display background images on the front and back of each Tile. Background images can be stored in isolated storage, but must be located in this folder or a subfolder of it.

This folder is created when your application is installed, but it can be deleted. For more information, see Tiles Overview for Windows Phone.

Shared/Transfers

Background file transfer: Applications can save files to isolated storage in the background, even when the application is no longer running in the foreground.

This folder is created when your application is installed, but it can be deleted. For more information, see Background File Transfers Overview for Windows Phone.

Use Isolated Storage Explorer (ISETool.exe), to list, copy, and replace files and directories in isolated storage in a Windows Phone application. Isolated Storage Explorer is a command-line tool that gets installed with Windows Phone SDK 7.1. This tool enables you to verify that files are being saved in the correct location with the correct data. Isolated Storage Explorer can be used in the emulator or a device. For more information, see How to: Use the Isolated Storage Explorer Tool.

The Windows Phone isolated storage APIs are derived from the Silverlight isolated storage APIs, the System.IO.IsolatedStorage namespace. However, there are some subtle implementation changes between the two. These changes are discussed in the following section. For more information about Windows Phone isolated storage APIs, see System.IO.IsolatedStorage Namespace.

Class and Windows Phone Namespace

Class and Silverlight Namespace

Purpose

How Windows Phone Isolated Storage APIs are Different from Silverlight

System.IO.IsolatedStorage.IsolatedStorageFile

System.IO.IsolatedStorage.IsolatedStorageFile

Represents an isolated storage area containing files and directories.

  • Windows Phone applications do not have a limit on the quota for storage on disk. The quota APIs reflect this, and GetUserStoreForSite is not available.

  • Windows Phone applications only have application storage. Since the application cannot have a site of origin, the site-specific storage APIs are not available to Windows Phone applications.

System.IO.IsolatedStorage.IsolatedStorageSettings

System.IO.IsolatedStorage.IsolatedStorageSettings

A dictionary that stores key/value pairs in isolated storage.

SiteSettings is not available.

Did you find this helpful?
(1500 characters remaining)