Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the appmanifest of a WinRT app destroys the apps data

In my WinRT-application I store user data (not session data) in a local file. The file is saved and loaded via ApplicationData.Current.LocalFolder.

Every time I make a minor change to the app-manifest, these saved files and the app settings will be invalidated and deleted on app startup. Is this only in the development environment so or will this also happen when the package has been published in the app-store?

How do I prevent the system from doing this? The user will be very unhappy if he loses his data due to a version change!

Update 1:
Thanks to Hans Passant, I have learnt that also data files have a Version. Setting the data file version has fixed the problem for version changes (increment only), but not for the rest of the manifest changes.

Update 2:
In the meantime I have also observed, that not only changing properties of the app manifest have this effect. If I add a new resource file for a new language (localization), the data will also be deleted. It would be really nice to know, if this odd behaviour will also be existent in installed apps published via the shop.

like image 815
HCL Avatar asked Sep 07 '12 11:09

HCL


1 Answers

The answer to my question seems not to be so easy. Eventually I have observed that it consists probably of two different issues. In the web I have found only very little Information, therefore all I write here is a little speculative, based on some simple tests I have done.

Version changes
Thanks to Hans Passant, I have learnt that data files may have a version. Due to a lack of documentation, I do the version test and version setting as follows:

await ApplicationData.Current.SetVersionAsync((uint)1, (setVersionRequest) => { });

The code is anytime executed before I load my data files. Because I have currently no changes in my file format, I leave the change callback empty {}.
After inserting the above code, version changes had no more deleted my apps data while changing the version properties. However, as a test I removed afterwards the code and unexpectedly, any version changes have no more deleted the apps data files either! Maybe because they now are versioned. (As a sidemark: decrementing the version results always in a loss of the data files).

General Manifest Changes
The effect that changing properties of the manifest (except the Version-properties) deletes the data has not been gone. If I change for example the description of the app, all data will be deleted. I have found some posts guessing that this will not occur in the store, but I have not found any evidence.

Addition of Languages
Another effect I have observed, is that if I add a new language to the app (adding a ressource-file) does the same.

Please note: All the above explanations are based on observations of my Development Environment. I have not found any concrete documentation and therefore I recommend everyone to test the concerned use cases very well for not making your clients very unhappy. Probably in some months, there will be more concrete documentation available.

like image 181
HCL Avatar answered Jan 03 '23 01:01

HCL