/**
* 获取是否播放声音
*/
publicstaticboolean playSounds(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SOUNDS, SOUNDS_DEFAULT);
}
/**
* 设置播放的声音
* @param context 上下文
* @param value 是否播放
*/
publicstaticvoid setPlaySounds(Context context, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(SOUNDS, value).commit();
}
/**
* 获取警告时间
* @param context 上下文
* @return 警告时间秒
*/
publicstaticint getWarningTime(Context context) {
String value=PreferenceManager.getDefaultSharedPreferences(context).getString(WARNING_TIME,Integer.toString(WARNING_TIME_DEFAULT));
try
{
return Integer.parseInt(value);
}
catch(NumberFormatException e)
{
setWarningTime(context, WARNING_TIME_DEFAULT);
return WARNING_TIME_DEFAULT;
}
}
/**
* 设置警告时间
* @param context 上下文
* @param warningTime 警告时间
*/
publicstaticvoid setWarningTime(Context context, int warningTime) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(WARNING_TIME, Integer.toString(warningTime)).commit();
}
/**
* 参加人数无限制
* @param context
* @return
*/
publicstaticboolean allowUnlimitedParticipants(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(UNLIMITED_PARTICIPANTS, UNLIMITED_PARTICIPANTS_DEFAULT);
}
publicstaticvoid setAllowUnlimitedParticipants(Context context, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(UNLIMITED_PARTICIPANTS, value).commit();
}
/**
* 允许编辑会议时间
* @param context
* @return
*/
publicstaticboolean allowVariableMeetingLength(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(VARIABLE_MEETING_LENGTH, VARIABLE_MEETING_LENGTH_DEFAULT);
}
publicstaticvoid setAllowVariableMeetingLength(Context context, boolean value) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(VARIABLE_MEETING_LENGTH, value).commit();
}
getDefaultSharedPreferences(Context )用来获取preferences.以后的操作就和普通的Sharedpreferences一样了,如果需要修改某项配置的信息,记得最后需要 commit()。