Reputation: 23
I have the following class:
public class UserPref {
Context context;
SharedPreferences sharedPref;
public SessionUtils(Context context) {
this.context = context;
sharedPref = context.getPreferences(Context.MODE_PRIVATE);
}
}
However, I get the following error on getPreferences()
:
Cannot resolve method 'getPreferences(int)'
Why? How do I fix this?
Upvotes: 1
Views: 3217
Reputation: 47807
It's like
SharedPreferences preferences = context.getSharedPreferences("AppPreferences", Activity.MODE_PRIVATE);
More about it Official Docs
Upvotes: 5