Domanda

In my Windows Phone application(silverlight application), I want the user to automatically get logged-in to the application once he logs in successfully. I.e I don't want the user to login everytime.

I achieved this through a Isolated Storage file concept. I.e First I created a directory and I created an isolated storage file stream and stored the email and password credentials in some file.
When I stopped debugging and start it back, my stream reader reads the email-password credentials from that file successfully.

My problem is when I close my emulator and open it back I could not read from that file.(particularly, the directory itself does not exist!).I also want to know my Isolated storage persists in real windows phone?

How could I fix this?

È stato utile?

Soluzione

This is by design.

The isolated storage in the emulator is not persisted after you close it.

Reference: Windows Phone Emulator Scroll down to "Features":

Important Note:
Isolated storage is available while the emulator is running. Data in isolated storage does not persist after the emulator closes. This includes files stored in a local database, as these files reside in isolated storage.

Altri suggerimenti

This is one draw back with using the emulator - it's not a problem on a real phone.

See http://msdn.microsoft.com/en-us/library/ff402563%28v=vs.92%29.aspx

Important Note: Isolated storage is available while the emulator is running. Data in isolated storage does not persist after the emulator closes. This includes files stored in a local database, as these files reside in isolated storage.

You can't do anything about that. When you close and re-open the emulator you wipe all data (apps, isolated storage contents, the lot) from the "device" and start again from a known state. One reason for this is to allow developer to go to a "known good" state of the device so that you can test from scratch on the emulator each time you relaunch it.

If you want to persist the data between launches of the app, your only option is to not shut down the emulator between runs.

You can also use the IsolatedStorageSettings.ApplicationSettings to store the user's credential rather than having to write a file:
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragesettings.applicationsettings%28v=vs.95%29.aspx

And as others have said, in the emulator, these settings only persist while the emulator itself is running. please note that you don't have to close the emulator in between each debugging session. You can press the home button on the emulator to test moving in and out of the application.

You can use the Isolated Storage Explorer Tool to take a snapshot of you app isolated storage (eg. with some default data in it) and then use that snaphot to reverse isolated storage content after emulator is restarted.

You can find more info about ISETool and some 'How to' on How to: Use the Isolated Storage Explorer Tool article on msdn.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top