tags:

views:

23

answers:

1

Will SharedPreference be destroyed if the Context has been destroyed?

For example, if the Context is an Activity, and this Activity has quit.

I tried in my code, and the SharedPreference turns to be null, as well as the Context.

I also tried to find some clues in the opensource code, but it's complicated for me.

A: 

SharedPreferences are there to store data. So the data should still be here, even if you restart your phone for example. So to answer your question: No, SharedPreferences are not destroyed.

However, to solve your problem you have to post some code.

Roflcoptr
Thanks Sebi, I admit that the SharedPreference is a file in the application's private directory. And I'm wondering whether a SharedPreference object will be destroyed if the Context has been destroyed
Johnny