title: Can't access SharedPreferences from my Service
body: <p><strong>What I'm trying to do</strong></p>
  
  <hr>
  
  <p>Hello Guys.</p>
  
  <p>I got a Service which, set's a boolean to true or to false whenever the service is started or stopped (started = true / stopped = false) in the SharedPreference. Now when I try to get the Boolean out there in my Activity, it allways dosn't find it. How can I solve this... Here's the Code for you Guys.</p>
  
  <p><strong>Code</strong></p>
  
  <hr>
  
  <p>Methode in my Service:</p>
  
  <pre><code>private void setStarted(boolean started) {
      // SharedPreferences casten
  
      mPrefs = this.getSharedPreferences(LOG_TAG, MODE_PRIVATE);
      // Boolean in SharedPreferences hinzufügen
      SharedPreferences.Editor editor = mPrefs.edit();
      editor.clear().apply();
      editor.putBoolean(PREF_STARTED, started).commit();
      editor.commit();
  
      //mPrefs.edit().putBoolean(PREF_STARTED, started).commit();
  
      Log.d(LOG_TAG, "Variabel " + mPrefs.getBoolean(PREF_STARTED, false));
  }
  </code></pre>
  
  <p>In my Activity</p>
  
  <pre><code>// mPrefs caten
          mPrefs = this.getSharedPreferences(GPSService.LOG_TAG, MODE_PRIVATE);
  
          // boolean holen ob service gestartet oder nicht
          run = mPrefs.getBoolean(GPSService.PREF_STARTED, false);
  </code></pre>
  
  <p>How do I get the boolean out of there? It allways returns me the default value I had to give in the getBoolean Methode.</p>
  
  <p>Thanks for your help in advance</p>
  
  <p>safari</p>