Change true false in preferences in java
<p>I'm attempting to use a Button from view class to turn off sound from app. (ie: mute)
When user pushes box i want code to check if value is already true or flase and then set to opposite using ID called 'mute'. I think i have the IF part setup, just need easy change SharedPreferences from true to flase and vice versa...</p>

<p>Here is code framework I'm testing(BEFORE):</p>

<pre><code>SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
boolean cmute = getPrefs.getBoolean("mute", defValue);
if (cmute == true){                     

}
if (cmute == false){

}
</code></pre>

<p>I have tried various findings for the solution but most are too complex for this simple need I think..</p>

<p>Here is my rework AFTER posted suggestion:</p>

<pre><code>if (cmute == false){


                    Editor editor = getPrefs.edit();
                    editor.putBoolean("mute", true);
                    editor.commit();
                    Editor editor2 = getPrefs.edit();
                    editor.putBoolean("notice", true);
                    editor.commit();



                }
                if (cmute == true){

                    Editor editor = getPrefs.edit();
                    editor.putBoolean("mute", false);
                    editor.commit();
                    Editor editor2 = getPrefs.edit();
                    editor.putBoolean("notice", false);
                    editor.commit();

                }
</code></pre>
