Is isolated storage always empty on the emulator?

in my WP7 application, I do:

string userName = IsolatedStorageSettings.ApplicationSettings.Contains("UserName") ? IsolatedStorageSettings.ApplicationSettings["UserName"].ToString() : null; if (string.IsNullOrEmpty(userName)) IsolatedStorageSettings.ApplicationSettings["UserName"] = "test"; 

I run my application (F5), of course, the username is empty, so it is stored in isolated storage.

I am stopping my application (stop debugging) and I am not closing the emulator

Run my application again (F5), but still empty.

I read that isolated storage should persist until the emulator is closed.

What am I doing wrong?

Thanks in advance for your reply.

+4
source share
2 answers

Have you tried to exit the application as usual? (by clicking the "Back" button in the emulator, and not by clicking the "Stop" button in Visual Studio). I think the contents of IsolStorageSettings.ApplicationSettings is saved when the application exits. The Stop button of Visual Studio kills the application, therefore, it prevents the launch of the save code.

+4
source

You also need to call

 IsolatedStorageSettings.ApplicationSettings.Save(); 

after changing the settings.

+6
source

Source: https://habr.com/ru/post/1396241/


All Articles