androidsharedpreferencesandroid-strictmode

Should accessing SharedPreferences be done off the UI Thread?


With the release of Gingerbread, I have been experimenting with some of the new API's, one of them being StrictMode.

I noticed that one of the warnings is for getSharedPreferences().

This is the warning:

StrictMode policy violation; ~duration=1949 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2

and it's being given for a getSharedPreferences() call being made on the UI thread.

Should SharedPreferences access and changes really be made off the UI thread?


Solution

  • I'm glad you're already playing with it!

    Some things to note: (in lazy bullet form)

    Regarding loading, though...

    Check the Android Developers blog for upcoming posts on StrictMode-related subjects in the coming week(s).