Back to project page silent-meeting.
The source code is released under:
GNU General Public License
If you think the Android project silent-meeting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.bensproule.silentmeeting.constants; //w w w.java2 s . co m import android.app.AlarmManager; import android.content.Context; import android.content.SharedPreferences; public class Setting { public static final String ACTIVE = "active"; public static final String ACTIVE_AFTER_EVENTS = "activeafterevents"; public static final String ACTIVE_BEFORE_EVENTS = "activebeforeevents"; public static final String POLLING_INTERVAL = "pollinginterval"; public static final String PREFERENCES_NAME = "options"; public static boolean getActive(Context context) { return getBoolean(context, ACTIVE); } private static boolean getBoolean(Context context, String setting) { SharedPreferences settings = context.getSharedPreferences(Setting.PREFERENCES_NAME, 0); try { return settings.getBoolean(setting, true); } catch (ClassCastException e) { return true; } } public static void setActive(Context context, boolean value) { setBoolean(context, ACTIVE, value); } public static void setBoolean(Context context, String setting, boolean value) { SharedPreferences settings = context.getSharedPreferences(Setting.PREFERENCES_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(setting, value); editor.commit(); } public static long getActiveAfterEvents(Context context) { return getLong(context, ACTIVE_AFTER_EVENTS); } public static long getActiveBeforeEvents(Context context) { return getLong(context, ACTIVE_BEFORE_EVENTS); } public static long getInterval(Context context) { long interval = getLong(context, POLLING_INTERVAL); if (interval < 1l) { interval = AlarmManager.INTERVAL_DAY; } return interval; } public static long getLong(Context context, String setting) { SharedPreferences settings = context.getSharedPreferences(Setting.PREFERENCES_NAME, 0); return settings.getLong(setting, 0l); } public static void setActiveAfterEvents(Context context, long value) { setLong(context, ACTIVE_AFTER_EVENTS, value); } public static void setActiveBeforeEvents(Context context, long value) { setLong(context, ACTIVE_BEFORE_EVENTS, value); } public static void setInterval(Context context, long value) { setLong(context, POLLING_INTERVAL, value); } public static void setLong(Context context, String setting, long value) { SharedPreferences settings = context.getSharedPreferences(Setting.PREFERENCES_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putLong(setting, value); editor.commit(); } }