title: if click on checkboxes my checklist should be save in Xml How?
body: <p>My checkboxlist are displaying but i want to check some list item which will save in xml for further use. how ?here is my list code, preference .. please explain me with code that how it will save my checkbox list.</p>
  
  <pre><code>public class MachinesCheck extends Activity implements IObserver {
        private StringBuffer buffer = new StringBuffer();
        private ListView mainListView ;
        private ArrayList&lt;Machine&gt; Machines ;
        private ArrayList&lt;Machine&gt; SelectedMachines ;
        private ArrayAdapter&lt;Machine&gt; listAdapter ;
        Vector&lt;MDCMachineStatus&gt; machineStatus_vector;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.machinecheck);
      SelectedMachines = new ArrayList&lt;Machine&gt;();
      MachineStatusSingleton.Register(this);
      getData();
  
  
      // Find the ListView resource. 
      mainListView = (ListView) findViewById( R.id.mainListView );
  
      // When item is tapped, toggle checked properties of CheckBox and Planet.
      mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick( AdapterView&lt;?&gt; parent, View item, 
                                 int position, long id) {
            Machine machine = listAdapter.getItem( position );
            machine.toggleChecked();
          MachineViewHolder viewHolder = (MachineViewHolder) item.getTag();
          viewHolder.getCheckBox().setChecked( machine.isChecked() );
  
          if (machine.checked)
          {
              SelectedMachines.add(machine);
          }
          else
          {
              SelectedMachines.remove(machine);
          }
        }
      });
  
  
  
  
      listAdapter = new MachineArrayAdapter(this, Machines);
      mainListView.setAdapter( listAdapter ); 
      mainListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    }
  
    private void getData(){
          machineStatus_vector = MachineStatusSingleton.GetData();
          //arrayListofMachines = new ArrayList&lt;String&gt;();
          //arrayListofMachineNumbers = new ArrayList&lt;String&gt;();
          Machines = new ArrayList&lt;Machine&gt;();
          for(MDCMachineStatus temp: machineStatus_vector){
              //arrayListofMachines.add(temp.toString());
              //arrayListofMachineNumbers.add(temp.getNumber());
              Machines.add(new Machine(temp.toString(), temp.getNumber()));
  
          }
  
  
  
      }
  
  
    private static class Machine {
          private String name = "" ;
          private String number ="";
          private boolean checked = false ;
          public Machine() {}
          public Machine( String name, String number ) {
            this.name = name ;
            this.number = number ;
          }
          public Machine( String name, boolean checked ) {
            this.name = name ;
            this.checked = checked ;
          }
  
           public String getName() {
            return name;
          }
          public void setName(String name) {
            this.name = name;
          }
  
          public String getNumber() {
                return number;
              }
              public void setNumber(String number) {
                this.number = number;
              }
  
          public boolean isChecked() {
            return checked;
          }
          public void setChecked(boolean checked) {
            this.checked = checked;
          }
          public String toString() {
            return name ; 
          }
          public void toggleChecked() {
            checked = !checked ;
          }
        }
  
  
    private static class MachineViewHolder {
          private CheckBox checkBox ;
          private TextView textView ;
  
          public MachineViewHolder( TextView textView, CheckBox checkBox ) {
            this.checkBox = checkBox ;
            this.textView = textView ;
          }
          public CheckBox getCheckBox() {
            return checkBox;
          }
          public void setCheckBox(CheckBox checkBox) {
            this.checkBox = checkBox;
          }
          public TextView getTextView() {
            return textView;
          }
          public void setTextView(TextView textView) {
            this.textView = textView;
          }    
        }
  
  
  
  
      private static class MachineArrayAdapter extends ArrayAdapter&lt;Machine&gt; {
  
          private LayoutInflater inflater;
  
          public MachineArrayAdapter( Context context, List&lt;Machine&gt; machineList ) {
            super( context, R.layout.selectedlist, R.id.rowTextView, machineList );
            // Cache the LayoutInflate to avoid asking for a new one each time.
            inflater = LayoutInflater.from(context) ;
          }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
        // Machine to display
          Machine machine = (Machine) this.getItem( position ); 
  
        // The child views in each row.
        CheckBox checkBox ; 
        TextView textView ; 
  
        // Create a new row view
        if ( convertView == null ) {
          convertView = inflater.inflate(R.layout.selectedlist, null);
  
          // Find the child views.
          textView = (TextView) convertView.findViewById( R.id.rowTextView );
          checkBox = (CheckBox) convertView.findViewById( R.id.CheckBox01 );
  
          // Optimization: Tag the row with it's child views, so we don't have to 
          // call findViewById() later when we reuse the row.
          convertView.setTag( new MachineViewHolder(textView,checkBox) );
  
          // If CheckBox is toggled, update the planet it is tagged with.
          checkBox.setOnClickListener( new View.OnClickListener() {
            public void onClick(View v) {
              CheckBox cb = (CheckBox) v ;
              Machine machine = (Machine) cb.getTag();
              machine.setChecked( cb.isChecked() );
  
            }
          });        
        }
        // Reuse existing row view
        else {
          // Because we use a ViewHolder, we avoid having to call findViewById().
          MachineViewHolder viewHolder = (MachineViewHolder) convertView.getTag();
          checkBox = viewHolder.getCheckBox() ;
          textView = viewHolder.getTextView() ;
        }
  
        // Tag the CheckBox with the Planet it is displaying, so that we can
        // access the planet in onClick() when the CheckBox is toggled.
        checkBox.setTag( machine ); 
  
        // Display planet data
        checkBox.setChecked( machine.isChecked() );
        textView.setText( machine.getName() );      
  
        return convertView;
      }
  
    }
  
    public Object onRetainNonConfigurationInstance() {
      return Machines ;
    }
  
  public void Update(ISubject arg0) {
      // TODO Auto-generated method stub
  
  }
    }
  </code></pre>
  
  <p>and here is my preference please check and tell me how it saved the data im xml file.</p>
  
  <pre><code>&lt;PreferenceScreen
                  android:key="DataEntryScreen"
                  android:title="Data Entry Machine"
                  android:summary="Select a Machine"&gt;
  
             &lt;/PreferenceScreen&gt;
  </code></pre>