Getting Static integer from Service
<p>I have activity and service, I would like to get a reference to Service integer, that is being updated from time to time in Service. My problem is that in my Activity I only get that integer first declared Value (for instance 0). </p>

<p>My main goal is to know Services' updated value every time I start my program.</p>

<p>Main activity:</p>

<pre><code>if(Service.doesCounter&gt;0){
                        //do something
                //in this state Service.doesCounter always is 0(checked by log)
        }
</code></pre>

<p>Service:</p>

<pre><code>public static int doesCounter=0; // declared after class as class memeber
//code where I start my method does();

.....
public void does(){
        doesCounter++;
        Log.e("cccccc","Service Counter "+doesCounter); // everything ok, value is changing as suppose to.
}
</code></pre>

<p><strong>Edit</strong></p>

<p>my Shared Preferences class:</p>

<pre><code>public class AppPreferences extends PreferenceActivity {
      @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

    private static final String APP_SHARED_PREFS = "com.aydabtu.BroadcastSMS_preferences"; //  Name of the file -.xml
         private SharedPreferences appSharedPrefs;
         private Editor prefsEditor;

         public AppPreferences(Context context)
         {
             this.appSharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
             this.prefsEditor = appSharedPrefs.edit();
         }

         public boolean getAnything() {
             return appSharedPrefs.getBoolean("Anything", false);

         }

         public void setAnything(Boolean text) {
             prefsEditor.putBoolean("Anything", text);
             prefsEditor.commit();
         }
</code></pre>

<p>Then from Main Activity:</p>

<pre><code>public class MainActivity extends Activity {
    protected AppPreferences appPrefs;
appPrefs = new AppPreferences(getApplicationContext());
appPrefs.setAnything(fasle);
</code></pre>

<p>Then from Service:</p>

<pre><code>appPrefs = new AppPreferences(getApplicationContext());
</code></pre>

<p>And when this happens all earlier made changes are reseted, how to make service and MainActivity use same prefs? Maybe I can somehow make AppPrefs class static?</p>
