ApplicationSettings Settings Not Saved Properly

I am trying to save two lists of objects in the ApplicationSettings phone, but I am stuck in a strange problem (but probably I am making a stupid mistake somewhere).

If I save only one of the lists, it works as expected - it will save it and restart it when the application is launched next time. But if I try to save 2 lists, none of them seem to be saved correctly. No errors or anything else, just "emptiness".

See the code below.

//My save method
public void Gem()
        {
            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains(INDTASTNINGER_LIST))
            {
                settings[INDTASTNINGER_LIST] = _indtastningsListe;
            }
            else
                settings.Add(INDTASTNINGER_LIST, _indtastningsListe);

            if (settings.Contains(INDTASTNINGER_LIST2))
            {
                settings[INDTASTNINGER_LIST2] = _indtastningsListe2;
            }
            else
                settings.Add(INDTASTNINGER_LIST2, _indtastningsListe2);
            settings.Save();
        }

        //Constructor supposed to load settings
        public Indtastninger()
        {
            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains(INDTASTNINGER_LIST))
            {
                _indtastningsListe = null;
                _indtastningsListe = (List<Indtastning>)settings[INDTASTNINGER_LIST];
            }
            if (settings.Contains(INDTASTNINGER_LIST2))
            {
                _indtastningsListe2 = null;
                _indtastningsListe2 = (List<Indtastning>)settings[INDTASTNINGER_LIST2];
            }
        }

What am I doing wrong? If I comment on the part with the material “list2”, the first will be saved / restored perfectly.

+5
1

, , IsolStorage, XML-.

, , , .

+2

All Articles