Storage Considerations

Windows Phone 7 does not include a general-purpose file system or a local database. The only option for storing data on the phone is to use isolated storage via an API to access a virtual hierarchy of folders and files that is private to the application. Although third-party database mechanisms are likely to be available, you should consider whether the additional memory and resource overheads that a database will impose are necessary for your application. The majority of Windows Phone 7 applications will typically use only isolated storage.

Note: In future releases, there may be a database available on the phone; or you may alternatively consider using a third-party database that you install with your application.

When storing data in isolated storage, the most common approach is to store it as serializable collections. The Tailspin Surveys client application discussed in this book uses isolated storage to hold collections of surveys and their content.

Storage is limited on mobile devices when compared to desktop and notebook computers. The minimum specification for Windows Phone 7 devices is 256 MB of memory, though manufacturers are likely to install more than this. The phone can also accept extended memory of up to 8 GB using a flash card.

Isolated storage on the device is shared among operating system data, built-in applications, user content (such as downloaded media), and other applications that the user installs on the device. Being a “good citizen” is especially important on the phone because there is no limit to the amount of data that an application can store (there are no per-application storage quotas). This means that your applications must minimize their use of storage without causing a reduction in performance of the device and your application. The following are some recommendations for using storage on the device:

  • Use the DeviceExtendedProperties class to see how much memory your application is using, and how much memory is installed and available. For more information about the Device ExtendedProperties class, see Appendix C, “Leveraging Device Capabilities.”
  • Make sure that your application cleans up and releases storage when it is no longer required, especially when the application is tombstoned or terminated.
  • Consider using caching to improve application performance, but only cache data that is regularly required and that does not affect the availability of isolated storage for other applications and services.
  • Consider compressing data that is placed in storage, though keep in mind that this will require additional processing and reduce battery life. You may be able to use data formats that are more compact; for example you might store configuration information or other types of data in binary or JSON format instead of XML format.
  • Ensure that sensitive data is encrypted, especially when it might be stored in removable media, such as a flash card.

Note: Typically, you will see the following effects, depending on the serialization method you choose:

XML: Larger payload, higher CPU utilization
JSON without compression: Smaller payload, lower CPU utilization
JSON with compression: Smallest payload, higher CPU utilization

 


Posted

in

by

Tags: