package com.nsgk.ruralWeb;

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

public final class Preference
{
    public static final String LAST_ACCESS_URL = "last_access_url";

    private final Context context;

    public Preference(Context context)
    {
        this.context = context;
    }

    private SharedPreferences Read()
    {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }

    private SharedPreferences.Editor Write()
    {
        return PreferenceManager.getDefaultSharedPreferences(context).edit();
    }

    public String GetString(String name, String...def)
    {
        return Read().getString(name, null != def && def.length > 0 ? def[0] : null);
    }

    public void SetString(String name, String val)
    {
        Write().putString(name, val).commit();
    }
}
