Mark Murphy wrote:
> 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();
>
>   

it may be the case... however I have run through the code a few times 
and didn't find an editor object that could be left open. Even if that 
is the case, I'd like to propose to the android dev team to make such 
coding errors less catastrophic... (not bashing just a suggestion - if 
for some reason an editor is left open the whole prefs should not 
disappear).


>> 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.
>
>   

1) files is something I understand... and have control over. dont know 
if I leave a file open, its contents will be gone for good... but its 
something I am about to experiment :P.

SQLite would be an option but is definitely more work for such simple 
tasks, and I have had some trouble with those too (specially with access 
from different threads...). You can call me lazy but in the end I just 
dont feel like spending much time on this type of functionality and 
rather concentrate on other aspects of the apps that I feel are way 
cooler :P.

Thanks for the input.
Filipe






--~--~---------~--~----~------------~-------~--~----~
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