/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.kneet.v3.common.gcm.support;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class BaseDefaultSharedPreferences {

    private SharedPreferences mSharedPreferences;

    protected BaseDefaultSharedPreferences(Context $context) {
        super();
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences($context);
    }

	/*
     * protected void clear() {
	 * SharedPreferences.Editor editor = mSharedPreferences.edit();
	 * editor.clear();
	 * editor.commit();
	 * }
	 */

    protected void remove(String $key) {
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.remove($key);
        editor.commit();
    }

    protected void put(String $key, String $value) {
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putString($key, $value);
        editor.commit();
    }

    protected String get(String $key) {
        return mSharedPreferences.getString($key, null);
    }

    protected void put(String $key, boolean $value) {
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putBoolean($key, $value);
        editor.commit();
    }

    protected boolean get(String $key, boolean $default) {
        return mSharedPreferences.getBoolean($key, $default);
    }

    protected void put(String $key, int $value) {
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putInt($key, $value);
        editor.commit();
    }

    protected int get(String $key, int $default) {
        return mSharedPreferences.getInt($key, $default);
    }

}
