Yikes! Two thoughts here. One, that switch statement is a bad idea
since the behavior in Honeycomb (and Ice Cream Sandwich, etc) will
revert back to a commit(), unless you're incredibly diligent about
updating your code in a timely fashion. The second and scarier thought
is that many times we're told that reflection can be used to figure
out if something is available or not. According to Dianne, reflection
could tell you that it's there but we still shouldn't use it because
it could be not-yet-ready-for-prime-time, even though it got released.
Important safety tip everyone!

- dave

On Dec 16 2010, 5:47 pm, "Raymond C. Rodgers"
<raym...@badlucksoft.com> wrote:
> I think what Dianne was suggesting might be something like doing a
> switch on the user's Android version... This isn't necessarily working
> code but should give you an idea:
>
> Edit e = prefs.Editor();
> e.put("Whatever","Data");
> switch(android.os.Build.VERSION)
> {
>      case Build.GINGERBREAD:
>           e.apply();
>      break;
>      default:
>         e.commit();
>
> }
>
> It's simple enough unless you have your preference writing routines
> scattered all over the place, in which case you could simply write a
> function to write preferences.
>
> Raymond
> On 12/14/2010 12:14 AM, shareem sharif wrote:
>
> > ture but no
>
> > On Mon, Dec 13, 2010 at 8:28 PM, Dianne Hackborn <hack...@android.com
> > <mailto:hack...@android.com>> wrote:
>
> >     You should do this based on API level.  If an API is not
> >     documented as available prior to a particular version, there are
> >     no guarantees what any existing method would do in the earlier
> >     versions.  For example, not infrequently a new API is being
> >     developed but hidden from a particular release because it is not
> >     ready yet due to being buggy or other reasons that could cause you
> >     trouble.  (I have no idea if that is the case here, but best to be
> >     safe.)
>
> >     On Mon, Dec 13, 2010 at 7:59 PM, Zsolt Vasvari <zvasv...@gmail.com
> >     <mailto:zvasv...@gmail.com>> wrote:
>
> >         As per theStrictModearticle (
> >        
> > http://android-developers.blogspot.com/2010/12/new-gingerbread-api-st...
> >         ), I devided to switch over using apply() instead of commit()
> >         for my
> >         SharedPreferences.
>
> >         So I wrote my nice conditional logic based on the API level and to
> >         test to see what happens, I ran it on my 2.2 Nexus One, fully
> >         expecting a VerifyError because of the missing API.  To my
> >         surprise, I
> >         didn't get that error.  So I fired up the emulator and
> >         confirmed that
> >         all the day down to Level 7, the supposedly new API does not
> >         trigger a
> >         VerifyError.  It does level 4 or below as expected.
>
> >         What's going on here?  Has the apply() method really been
> >         there since
> >         Level 7 undocumented?  If so, is it safe for me to check if the
> >         current API level >= 7 and use apply()?
>
> >         --
> >         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
> >         <mailto:android-developers@googlegroups.com>
> >         To unsubscribe from this group, send email to
> >         android-developers+unsubscr...@googlegroups.com
> >         <mailto:android-developers%2bunsubscr...@googlegroups.com>
> >         For more options, visit this group at
> >        http://groups.google.com/group/android-developers?hl=en
>
> >     --
> >     Dianne Hackborn
> >     Android framework engineer
> >     hack...@android.com <mailto:hack...@android.com>
>
> >     Note: please don't send private questions to me, as I don't have
> >     time to provide private support, and so won't reply to such
> >     e-mails.  All such questions should be posted on public forums,
> >     where I and others can see and answer them.
>
> >     --
> >     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
> >     <mailto:android-developers@googlegroups.com>
> >     To unsubscribe from this group, send email to
> >     android-developers+unsubscr...@googlegroups.com
> >     <mailto:android-developers%2bunsubscr...@googlegroups.com>
> >     For more options, visit this group at
> >    http://groups.google.com/group/android-developers?hl=en
>
> > --
> > 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

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