Code example for SwitchPreference

Methods: isChecked

0
		case 1: 
			helper = new EventTaskDBHelper(this);
			EventTask task;
			String event = (String) eventPreference.getSummary();
			String op = (String) opPreference.getSummary();
			int enable = (switchPreference.isChecked()) ? 1 : 0;
			if (event == null || op == null) {
				helper.close();
				return false; 
			} 
 
			if (add) {
				ArrayList<EventTask> data = new ArrayList<EventTask>();
				task = new EventTask(event, op, enable);
				data.add(task);
				helper.insert(data);
			} else { 
				task = new EventTask(id, event, op, enable);
				helper.update(task);
				EventTaskFragment.adapter.notifyDataSetChanged(); 
Experience pair programming with AI  Get Codota for Java