I also saw the prefs being lost ocassionally, especially after update or
reinstall. I haven't seen it happen (yet) after quoting, but maybe that's
just luck.

I will also add a call to setPersistent to my app see if that helps.

On Thu, Apr 23, 2009 at 1:12 PM, scanning_it
<festival.s...@googlemail.com>wrote:

>
> Thank you for your responses. By the way I love Nubinews. :)
>
> It is a known bug that & signs lead to a loss of shared prefs. But my
> settings don't include these signs. :( I have only the following
> things included as strings:
>
> content://media/internal/audio/media/33
> 100,200,300,400....
>
> So this can't be the problem with my settings loss. :( I will try
> using to quote the strings right now and I hope to fix the problems
> with that. My problem ist that I can't reproduce the bug on a daily
> basis. Often it works with the same settings for weeks and suddenly
> the prefs are gone.
>
>
>
> On Apr 23, 7:09 pm, Mattaku Betsujin <mattaku.betsu...@gmail.com>
> wrote:
> > I found that the preferences XML will break very easily if you store some
> > Strings containing 'special' characters. I am not sure what exactly those
> > are, but when I stored things like
> >
> >      putString("someurl", "http://xyz/?a=b&c=d";)
> >
> > the preference file becomes empty next time I try to open it.
> >
> > My solution is to quote all Strings that I put into the
> SharedPreferences.
> > After that my problems seems to go away.
> >
> > I couldn't find a Base64 encoder in the Android API, so I wrote a
> > quick-and-dirty PrefQuote class:
> >
> > http://code.google.com/p/nubi/source/browse/trunk/android/nubinews/sr...
> >
> >      putString("someurl", PrefQuote.quote("http://xyz/?a=b";))
> >
> > Hope this helps
> >
> > On Thu, Apr 23, 2009 at 9:56 AM, bo <bost...@gmail.com> wrote:
> >
> > > I do SharedPreferences.Editor.commit() in couple of places. 1.
> > > Immediately after setting the preference. 2. in Activity#onStop.
> > > Nevertheless when I restart the app the preferences are gone. Any more
> > > ideas? I do create prefs programmaticaly after harvesting these from
> > > user (username/pwd)
> >
> > > On Apr 21, 11:00 pm, Chander Pechetty <cspeche...@gmail.com> wrote:
> > > > Sorry, I was referring to the settings created using
> > > > PreferenceActivity screen using xml. Your actual preference values do
> > > > not help much in diagnosing the issue.
> >
> > > > Example snippet from loadingpreferencesfrom xml:
> > > >                     <CheckBoxPreference android:key="pref1"
> > > >                         android:title="pref1"
> > > >                         android:summaryOn="SummaryOn"
> > > >                         android:summaryOff="SummaryOff"
> > > >                         android:defaultValue="true"
> > > >                         android:persistent="true"/>
> >
> > > > Forpreferencescreated programatically, you can use
> > > > Preference.setPersistent(true);
> >
> > > > If no Settings screen is present, and everything is through your
> > > > program, then batch SharedPreferences.Editor.commit()'s should be
> > > > fine.
> >
> > > > I had a similar problem as yours, but have not faced it again so far.
> > > > Other than the known issue mentioned in the previous post, I don't
> > > > know what else the problem could be unless you post your code
> > > > perhaps...
> >
>

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