Thursday, December 26, 2013

Android: Accessing shared preferences in Activity

I was getting this error when trying to access shared preferences in my main activity:

http://stackoverflow.com/questions/12201371/android-unable-to-start-activity-componentinfo

Moving getPreferences() to the onCreate() method solved the problem.  I'm guessing it's because I was trying to get the shared preferences before the activity was created.  (Hey, I'm new at this!)