Reputation: 2063
I am attempting to build an application using Xamarin's Mono stuff (MonoTouch and MonoDroid). I am trying to write some code that will allow me to place content in local storage. Coming from a Windows Phone background, I thought this was the recommended approach in the Xamarin world also. On Windows Phone, I would have done the following:
IsolatedStorageSettings clientStorage = IsolatedStorageSettings.ApplicationSettings;
if (clientStorage != null)
{
if (clientStorage.Contains("myKey"))
clientStorage["myKey"] = value;
else
clientStorage.Add("myKey", value);
clientStorage.Save();
}
While the Xamarin stack provides System.IO.IsolatedStorage
, it does not provide the IsolatedStorageSettings
class. Now, I feel stuck and I cannot find an example. My question is, how do I put a value in Isolated Storage in a Mono app?
Thank you
Upvotes: 2
Views: 7467
Reputation: 1
The official mono project provides an implementation for IsolatedStorageSettings.
You can find it at: https://github.com/mono/moon/blob/master/class/System.Windows/System.IO.IsolatedStorage/IsolatedStorageSettings.cs.
Just add the file to your project and add "System.Runtime.Serialization" to your references.
The class creates a file "__LocalSettings" in the app directory and uses the DataContractSerializer to serialize your settings.
Upvotes: 0
Reputation: 2188
IsolatedStorageSettings is not implemented in the mobile solutions. It looks like it can be added, per that post, but it would have to be a custom implementation.
Generally though, you have a few other options.
Upvotes: 4