Jaa


What storage is right for me?

Developers moving across all three of the platforms supported by XNA Game Studio might find themselves working with their storage code to create a single codebase that works across all three. One of the main confusions can be the issue of what actually works on each of the platforms. Here’s a small table that quickly sums up what you have on each platform:

 

StorageDevice/StorageContainer

IsolatedStorage
Windows Yes Yes
Windows Phone 7 No Yes
Xbox 360 Yes Yes

Allow me now to elaborate on the Xbox 360 implementation of isolated storage as that is likely the most interesting part of this post. A few high level points can be made to give some details about how isolated storage works on Xbox 360:

  • IsolatedStorageFile is analogous to the StorageContainer API. This means you can only have one open at a time and you need to dispose of it in order to commit the changes.
  • IsolatedStorageFile is a non-player specific container, so it cannot be used for player specific save files.
  • IsolatedStorageFile’s underlying container appears in the Xbox UI as “Storage for [Game Title]”; there is no way to customize this as there is with StorageContainers.
  • Given that GetUserStoreForApplication() isn’t as asynchronous method, IsolatedStorageFile will not prompt the user for a storage device. It will always attempt to create the container on the same device as the game. This has a few notable results:
    • No UI popups; your game simply has access to the data.
    • Your user cannot choose the device on which their data is saved.
    • If the device holding the game is full or close to it, you may not be able to save enough data or even create the container.
    • If the game is moved from one device to another after the container is created, the game will not see the old container unless it is also moved.

So as the title says, “what storage is right for me?”

Generally speaking the recommendation for games on Xbox 360 is to use the StorageDevice/StorageContainer APIs. These are what professional titles for XBLA and retail will use (or the native equivalents) and will therefore make your game feel more at home in the ecosystem. Isolated storage is there if it fits your needs and your desired experience, but be mindful of the limitations that come with that API as you work on your game.

Comments

  • Anonymous
    November 12, 2010
    Good post. Thanks. It explained a few things I was wondering about. It looks as though IsolatedStorage was created for the WP7 since the existing storage classes/methods weren't really proper for it. I wonder if that's true.

  • Anonymous
    November 17, 2010
    IsolatedStorage has existed in Silverlight and .NET for a while now. It exists on WP7 because of the choice to use the Silverlight version of .NET for the phone. We didn't bring the XNA Storage APIs to the phone because it didn't seem to add much value and most of the concepts of our API don't make much sense on that platform. We did adapt the StorageContainer methods to match signature-wise with IsolatedStorageFile which should help make it easy to use minimal conditional compilation to make storage code work across both types of storage APIs: #if WINDOWS_PHONE public void SaveSomething(IsolatedStorageFile storage) #else public void SaveSomething(StorageContainer storage) #endif {   // do something with storage as long as it's one of the methods both support }