How do you use the Preference to keep data when using SurfaceView?



  • It would be desirable to maintain data using Preferecnce. But trying to use the method

    mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
    

    The studio is fighting. getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

    However, with the use of XML Activity, the studio behaves quietly to recognize this method.

    What can we do about it?



  • getSharedPreferences - it's a class method. Context, activate - the heir of the context, and it can directly trigger this method, and in the context, it needs to be triggered.

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

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2