The K-9 project has definitely seen this.  Would be nice to have a fix.

On Mon, Feb 23, 2009 at 9:39 PM, rod <rxxxxxx...@gmail.com> wrote:

>
> It appears to me that the SharedPreferences implementation is NOT
> thread safe.
>
> The implementations of Context.getSharedPreferences() and Editor.commit
> () do not synchronize on the same monitor.
>
> A call to getSharedPreferences() can return a new empty instance if
> there is a concomitant thread in the process of committing.
>
> In this case the getSharedPreferences() call may see the underlying
> preference file as changed. Should it see the file is changed and
> subsequently load the file from disk while it is unable to read or
> reads an invalid (only partially written file), it will fail silently
> and return a new instance.
>
> I see many posts suggesting that it is thread safe, not multi-process
> safe. But there's no shortage of folk reporting sporadic loss of
> preferences in a multi-threaded application. Perhaps i'm not correctly
> reading the source... Does anyone concur?
>
> Thanks,
> Rod
>
> >
>

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

Reply via email to