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 <[email protected] <mailto:[email protected]>> 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 <[email protected]
    <mailto:[email protected]>> wrote:

        As per the StrictMode article (
        
http://android-developers.blogspot.com/2010/12/new-gingerbread-api-strictmode.html
        ), 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
        [email protected]
        <mailto:[email protected]>
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:android-developers%[email protected]>
        For more options, visit this group at
        http://groups.google.com/group/android-developers?hl=en




-- Dianne Hackborn
    Android framework engineer
    [email protected] <mailto:[email protected]>

    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
    [email protected]
    <mailto:[email protected]>
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:android-developers%[email protected]>
    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 [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

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