Monday, January 14, 2013

Preferences in Monodroid.

Jared, a coder that's helping me out sometimes, went and found this gem.

Been trying to get him to post on here, but instead I'll post his code that he dug up for me.

Had to tweak what he put in, to work a bit cleaner in the app, but it was great research done,
and I really needed it for a deployment about a week ago.

            ISharedPreferences prefs = GetPreferences (FileCreationMode.Append);
            ISharedPreferencesEditor editor = prefs.Edit ();
            editor.PutString ("LoginName", creds);
            editor.Commit ();

This code will let you pretty much append anything you need via code into your preferences.

You just need to put in your string for the preference name.. and the value.  You can, of course, change the type a bit there in that editor variable.

No comments:

Post a Comment