Code example for SwitchPreference

Methods: isChecked

0
		case 1: 
			helper = new TimeTaskDBHelper(this);
			TimeTask task;
			String time = (String) timePreference.getSummary();
			String op = (String) opPreference.getSummary();
			int enable = (switchPreference.isChecked()) ? 1 : 0;
			if (time == null || op == null) {
				helper.close();
				return false; 
			} 
 
			if (add) {
				ArrayList<TimeTask> data = new ArrayList<TimeTask>();
				task = new TimeTask(time, op, enable);
				data.add(task);
				helper.insert(data);
			} else { 
				task = new TimeTask(id, time, op, enable);
				helper.update(task);
				TimeTaskFragment.adapter.notifyDataSetChanged(); 
Stop searching for code, let great code find you!  Add Codota to your java IDE