The reason you're getting a StackOverflowError
is because your method is recursively calling itself ad infinitum. If your class Main
is a subclass of Activity
, you merely need to call:
this.getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
If, indeed, you do need information from Shared Preferences in another class, it would be advisable to retrieve it in your Activity
and then pass the info to the class through a constructor, a public method, etc.