One of the new sets of APIs available with Windows* Runtime (WinRT) is called “Files and Folders.” These APIs provide easy access to storing data relevant to an application, like reading and writing files. But before digging into the available resources, it may be useful to understand what the reason is for this new set, given that storing files is so common in programming. The reason is to improve the user experience by saving the application data and enabling the user to pick up where the application was left on the last time. It’s also related to new resource management by Windows 8, to improve system performance.
In this document, I’ll explain the new model of storing application data, how to keep your application data updated, and the details for these APIs. And by “application data,” I mean settings, cache, or preferences, which are different than User Data, which can be any media file created or stored by the user.
|App Data||User Data|
Keeping your app updated
With the expansion of personal devices into everyday life, developers need to keep the user experience in the in the forefront of their designs. Not doing so can result in failure of a product. In our case, this product is one application, and there are several features, from performance to usability, that influence the user perception. To understand the reason for the new APIs, we need to take the user’s perspective—when using the application, closing the application, either because the device is locked or the user opened another application. What will the user find when the application is opened again? Users expect their applications to save their last settings, know where they stopped, and bring that point to the front when opening that application again.
Remember that restarting from the last point can happen in several scenarios. The user could have ended the application, have opened another application and the first one went to background, or may have closed the lid and the computer is in standby. Also, the application may have been closed by the new set of Windows 8 development directives.
Microsoft created new directives to give Windows Store apps development a strong push for better performance and power management. When the user moves away from one application, the OS puts this application on standby. If the system is running low on memory, the Windows management system will send a signal informing the application that it will be shut down in 5 seconds. There is no way to avoid this, so applications should save their data frequently to avoid last minute writing, which can take time and performance and may not finish in time.
So we have three things to keep in mind when thinking about the application data storage: users expect the application to resume from the last point they left it; the application may just resume or go from a fresh new start; desktop applications may use these resources, but Windows Store apps are required to follow development guidelines and keep app data updated. The APIs for Files and Folders, especially the new ApplicationData class, provides resources to save and restore settings and user preferences.
Desktop vs Windows Store apps
As you may be aware, you need to follow certain steps if you want to expose WinRT APIs to Desktop applications. In this article you can find the steps on how to do adjust Visual Studio for using WinRT APIs for Desktop applications. The new rules of enforcement described earlier are applicable for Windows Store apps, but it is a good idea for your application to also follow those rules.
If you are developing a Windows Store app, these steps are not required, as Visual Studio already have them when you create a Windows Store style application.
On MSDN, you can find sample codes that can help you put into practice what I’ve described: Quickstart on how to access files programmatically and how to save local applications data.
Keeping your app updated and saving data regularly will provide a much better experience for your user, and satisfied users are more likely to promote your application. So how about refreshing your app now?