Android - save toggle and preferences states
<p>I am trying to create a class on my project to select some toggles and preferences and at the end to create one file for each toggle or preference on my sdcard. But I need help.</p>

<p>How do I store 2 files(text files without extention) with particular name on sdcard based on the selections I did, like:</p>

<ul>
<li>"/sdcard/TEST/toggle1_on" if toggle1 was selected or "/sdcard/TEST/toggle_off" if not selected</li>
<li>"/sdcard/TEST/list_option3" if was selected option 3 or "/sdcard/TEST/list_optionX" for the number X selected</li>
</ul>

<p>This is my class:</p>

<blockquote>
  <p>package org.android.teste;</p>
  
  <p>import ...</p>
  
  <p>public class Config extends
  PreferenceActivity {</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setPreferenceScreen(createPreferenceHierarchy());
}

private PreferenceScreen createPreferenceHierarchy() {
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

    // Inline preferences 
    PreferenceCategory inlinePrefCat = new
</code></pre>
  
  <p>PreferenceCategory(this);
          inlinePrefCat.setTitle(R.string.inline_preferences);
          root.addPreference(inlinePrefCat);</p>

<pre><code>    // Toggle1
    CheckBoxPreference toggle1 = new CheckBoxPreference(this);
    toggle1.setKey("toggle1");
    toggle1.setTitle(R.string.title_toggle1);
    toggle1.setSummary(R.string.summary_toggle1);
    inlinePrefCat.addPreference(toggle1);

    // List
    PreferenceCategory dialogList = new PreferenceCategory(this);
    dialogList.setTitle(R.string.dialog_list);
    root.addPreference(dialogList);

    // Chooser
    ListPreference listChooser = new ListPreference(this);
    listChooser.setEntries(R.array.entries_chooser);
    listChooser.setEntryValues(R.array.entryvalues_chooser);
    listChooser.setDialogTitle(R.string.dialog_title_chooser);
    listChooser.setKey("chooser");
    listChooser.setTitle(R.string.title_chooser);
    listChooser.setSummary(R.string.summary_chooser;
    dialogDrivers.addPreference(listChooser);

    return root;
}   }
</code></pre>
</blockquote>

<p>Any help on how to make my application read the sates of toggles and selections on exit and create the files on my sdcard I will be very greatfull.  </p>
