Filipe Abrantes wrote:
> indeed... i am experiencing this problem. my app uses a background 
> service that sometimes gets killed by the system. When that happens the 
> sharedprefs are lost. If the app force closes due to some unhandled 
> exception the prefs are also lost for good. 

I have had many, many force-closes, and none of them have damaged shared
preferences.

Are you holding an open editor object? I can definitely see where that,
coupled with a force-close, might cause problems. As was suggested
earlier in the thread, commit your editors as soon as possible:

settings
        .edit()
        .putString(SOME_STRING, "Hello world.")
// maybe some more put...() method calls here
        .commit();

> Im moving to good old .conf files :P...

What makes you think that will help?

Shared preferences are stored in "good old" flat files, in XML format.
Switching to some other form of flat file is unlikely to improve your
situation.

If you want transactional integrity, use a SQLite database.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to