Get SharedPreferences from a Service

I am trying to access general settings from a service. I used the following to save the value of text in a string ...

SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("Ignore1_value", Example.getText().toString());
editor.commit();

But how do I get the value in the service? Everything I tried returns like nothing. Any help would be perfect and much appreciated?

I looked through other questions, but without a solution. I came up with this, but as I said, it returns it as text.

Context ctx = getApplicationContext();
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
    String example1string = sharedPreferences.getString("Ignore1_value","");
    Log.i("**GetSettings", example1string);
+5
source share
1 answer

I always use PreferenceManager.getDefaultSharedPreferences(context). This is the same for everyone Contextin your application.

A Serviceis itself Context, so this would be enough:

PreferenceManager.getDefaultSharedPreferences(this);
+5
source