WinRT - Roaming App Settings - Are they persisted across versions? - c#

I was reading the MSDN article about "Accessing App Data with WinRT":
http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
In the section Roaming App Data it says:
If the app data on a device is updated to a new version because the
user installed a newer version of the app, its app data is copied to
the cloud. The system does not update app data to other devices on
which the user has the app installed until the app is updated on those
devices as well.
It also says that the Roaming App Data is deleted if the app is not used for 30 days.
I think that "Roaming App Data" refers to ApplicationData.Current.RoamingFolder.
I don't understand if the same thing applies to Roaming Settings (ApplicationData.Current.RoamingSettings.Values). Are they also not shared across versions? Are they also deleted after not using app for 30 days?

RoamingSettings use the same engine as the roaming application folder. So, the same restrictions apply. Data may be expired after 30 days if not accessed.
I'd suggest you consider the roaming settings as a convenience, and if the 30 days will be an issue, keep important settings locally and consider the roaming as a convenient way to synchronize settings when the application is used more frequently. You could also potentially use something like OneDrive to store settings if needed.
There are group policy settings that can disable roaming and OneDrive though.

Related

Windows Phone 8.1 How to permanently remove Roaming Settings?

I've stored some data in the ApplicationData.Current.RoamingSettings following the Example here http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700362.aspx .
The problem is that after storing the data in the RoamingSettings and then removing the same data using ApplicationData.Current.RoamingSettings.Values.Remove(key) (I've checked and actually the data are no more there), if I Uninstall and re-install the App on my Phone the Data I've deleted are back in RoamingSettings...
I've tried also ApplicationData.Current.ClearAsync() that clean all but after uninstalling and re-installing the app same thing.. the data are back.
Any suggestions?
RoamingSettings are designed to work like that. They can be used to store settings between devices. After you uninstall the App from all devices, the settings would persist in the cloud for some time in case the User installs the App again. If you want to use only local data - take a look at LocalSettings.
You will find more information about Guidlines for Roaming Data here at MSDN.
And here at the blog you will find similar answer:
Q. What happens to roaming app data when an app is uninstalled?
A. As noted in the previous question, an app’s app data folders are removed from a device when the app is uninstalled. Roaming app data, however, persists in the cloud so long as the user has the same app installed on other devices. When the user uninstalls the app from all of his or her devices, roaming app data continues to persist in the cloud for a reasonable time (a matter of a few weeks) so that it’s still available if the user decides to reinstall the app within that time. Note that when you make a change to an app project in Microsoft Visual Studio and that change (such as changing the manifest) forces a full reinstall, app data is removed as part of the process. References: Guidelines for roaming app data(overview docs).
So your to remove permanently your RoamingSettings you will have to wait.
EDIT - thanks to Pablo we have more detailed information here at MSDN:
Roaming data for an app is available in the cloud as long as it is accessed by the user from some device within the required time interval. If the user does not run an app for longer than this time interval, its roaming data is removed from the cloud. If a user uninstalls an app, its roaming data isn't automatically removed from the cloud, it's preserved. If the user reinstalls the app within the time interval, the roaming data is synchronized from the cloud. The current policy specifies that this time interval is 30 days.

local vs roaming vs temporary windows app data

I am trying to use the correct class for storing data in my windows app. I used IsolatedStorageSettings on the Windows Phone app, but I need to use the Windows.Storage class in my Windows store App begin written with VS Express 2013
I need the data to remain secure on the device when the app is not in use and don't want it to be saved in the cloud or removed unless the use logs out of the app. SO it just need to stay secure while the user remains logged in regardless if they are using the app or its in the background or Windows shut it down for memory reasons.
I suspect roaming is not the way to go but which should I use: local or temporary?
OK, after some more research I found this.
http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
Looks like local app data is the correct method as temporary data can be removed by the device at any time. Roaming as it says is for data that you want to use across devices that is stored on OneDrive(old Skydrive).
And if someone needs the example code then here is the link for a simple example.
local
Data that exists on the current device and is backed up in the cloud.
roaming
Data that exists on all devices on which the user has installed the app.
temporary
Data that could be removed by the system at any time.
localcache
Persistent data that exists only on the current device.

Should the potential disadvantage of roaming settings cause me to duplicate them in local settings?

There are two scenarios where storing my app's settings locally would seem preferable to roaming/in the cloud, namely:
1) When the user has (temporarily) lost internet connectivity
2) When/if retrieving roaming settings perceptibly impacts performance
So I'm thinking of storing settings both locally and via roaming, and only retrieving the roaming settings when I detect the device currently being used to run my app is not the
one normally/initially used. Of course, I would still need store the roaming settings along with the local settings in any case.
IOW, I want to store locally for the scenarios mentioned above, but I also want to roam the settings in the event the user is using my app with a different device than originally.
Is this a sensible approach (duplicating settings both locally and in the cloud)? If so, is there a way to accomplish this semi-automatically rather than duplicating all the settings storing code?
Roaming settings are available offline. The only difference is that they will sync to other devices if you are online. If you're offline it will just use the most recent version you have until you go online again.

Correct way to handle roaming data storage with C# in Metro?

I'm creating a C# Metro/Modern UI app, and I need a way to handle some user data (mostly just small strings, but a fair amount of them), and specifically I'd like the data to 'roam' with a user's Microsoft Account. I know that you can handle this with roamingSettings, but it seems like that's supposed to be used more for like storing user IDs and other one-time settings, whereas I would be using it to store all of my app's data, and there seems to be a limit to the amount of space I get with that. I was thinking about using SkyDrive to host a "MyApp Data" folder, but I can't seem to figure out how to upload a simple text file to it :(
It seems like the best way to handle it would be to set up an account on Azure or EC2 and then make a simple PHP API so I could access the SQL database from my app, but I'd rather not have to pay for hosting.
I've seen other questions about Metro app storage on StackExchange and Microsoft's own forums, but most of those are in reference to local storage and using SQL servers to handle the storage.
So should I just use roamingSettings and keep an eye on the quota, should I try to use cloud hosting, or is there a better solution I just haven't thought of yet?
Thanks!
A few things about roaming settings:
- they are intended for that, settings. Not as a data replication scheme, thus the quota
- they are not immediate. You can create a setting named "highpriority" that will replicate in less than a minute, but other settings can take several minutes to replicate. If you need data to be available immediately, roaming settings are not an option. Also, if you exceed quota all your data will stop replicating, which is a bad thing. :) It also will not replicate between different versions of your app even if the settings are the same. In addition, if you do not use the app for a period of time (default is 30 days), then the roaming data will be deleted from the cloud. I am pretty sure roaming data can also be turned off via group policy in enterprise settings.
You can leverage SkyDrive. Make sure you download the Live SDK. Overview of using SkyDrive is here... http://msdn.microsoft.com/en-us/library/live/hh826521.aspx It is, fundamentally, just a collection of REST APIs. See the SkyDrive photo sample for an app that uploads files to SkyDrive http://code.msdn.microsoft.com/windowsapps/Live-SDK-Windows-Developer-8ad35141
I would go for a cloud based solution. A MS employee told me that the roaming data is a "best effort" there is no control if it actually works, sometimes it works, sometimes it just doesn't.
Personally I'd try to use the skydrive option

Are there any issues with Isolated Storage and Windows Vista?

My problem is similar but not the same as that exhibited in:
"Could not find file" when using Isolated Storage
I've written an application that saves user settings in a file in isolated storage, I'm using the user store for assembly storage.
The application checks for a file in Isolated Storage on startup, and if it's not there assumes that it's the first time the application has been run and asks the user to configure it, this process then saves to Isolated Storage.
In Windows XP this works fine, I've not seen any issues whatsoever. However, I was running a demonstration to the client on their Windows Vista laptop and when I ran the client for the 2nd time to show that the settings were saved the application couldn't find the file.
Are there any known issues that might cause this to happen in Windows Vista and not Windows XP?
Both references to retrieve Isolated Storage are in the same .cs file, so it's definitely the same assembly that is making the call, and I didn't log in as another user, so I know it's the same user.
Isolated storage location will change as soon as you change the application version.
The proper place to store application configuration is in \ProgramData for all users and \Users\\AppData for user settings.

Categories