This doesn't really have anything to do with SharedPreferences or your ListAdapter... this is Java basics.
getApplication() isn't some global static function that can be called from anywhere, it can be called however from an Activity. Since your adapter is an instance with the Activity as a parent, you need to reference it. If your activity is named MyActivity you can do: SharedPreferences settings = PreferenceManager. getDefaultSharedPreferences(MyActivity.this.getApplication()); On Tuesday, October 16, 2012 3:16:33 AM UTC+2, lbendlin wrote: > > I have a custom list view adapter > > *public* *class* CustomListAdapter *extends* ArrayAdapter<String> > > > that I use to modify list view cells. Now I have the need to modify some > cells' content based on a global variable from the SharedPreferences. > > However, the adapter tells me it doesn't understand getApplication() so > > > SharedPreferences settings = > PreferenceManager.getDefaultSharedPreferences(getApplication()); > > > doesn't work. How else am I supposed to get the application context ? via > a static variable in the application singleton? > -- 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