I would like to implement data storage using Preferecnce. But when trying to use the method

mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE); 

Studio swears on getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

However, when using XML Activity, the studio calmly recognizes this method.

What can be done with this?

    1 answer 1

    getSharedPreferences is a method of the Context class, activations are the heir to the context and in it you can call this method directly, in the view you need to call it on the context.

     mSettings = getContext().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);