package de.sopa.manager;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * David Schilling - davejs92@gmail.com
 */
public class SettingsService {

    SharedPreferences sharedPreferences;
    private static final String PREFS_NAME = "MyPrefsFile";
    private String MUTE = "mute";

    public SettingsService(Context context) {
        sharedPreferences = context.getSharedPreferences(PREFS_NAME, 0);
    }

    public boolean isFirstTime() {
        String my_first_time = "my_first_time";
        if(sharedPreferences.getBoolean(my_first_time, true)) {
            sharedPreferences.edit().putBoolean(my_first_time, false).apply();
            return true;
        }
        return false;
    }

    public boolean isMute(){
        return sharedPreferences.getBoolean(MUTE, false);
    }

    public void switchMute() {
        sharedPreferences.edit().putBoolean(MUTE, !sharedPreferences.getBoolean(MUTE, true)).apply();
    }
}

package de.sopa.manager;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * David Schilling - davejs92@gmail.com
 */
public class SettingsService {

    SharedPreferences sharedPreferences;
    private static final String PREFS_NAME = "MyPrefsFile";
    private static final String MUTE = "mute";
    private static final String MY_FIRST_TIME = "MY_FIRST_TIME";

    public SettingsService(Context context) {
        sharedPreferences = context.getSharedPreferences(PREFS_NAME, 0);
    }

    public boolean isFirstTime() {
        if(sharedPreferences.getBoolean(MY_FIRST_TIME, true)) {
            sharedPreferences.edit().putBoolean(MY_FIRST_TIME, false).apply();
            return true;
        }
        return false;
    }

    public boolean isMute(){
        return sharedPreferences.getBoolean(MUTE, false);
    }

    public void switchMute() {
        sharedPreferences.edit().putBoolean(MUTE, !isMute()).apply();
    }
}

fix inconsistenct between mute state and button