EditText 'text' to sdcard
<p>I have a simple app where I want to be able to save the contents of a EditText control so the user to be able to add free format text and store it on a text file</p>

<p>I have the control in main.xml </p>

<pre><code>&lt;EditText
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="text in here"
        android:id="@+id/editText" android:layout_gravity="center"/&gt;
</code></pre>

<p>And a menu item </p>

<pre><code>&lt;item android:id="@+id/menu_add"
      android:icon="@drawable/ic_menu_add"
      android:title="@string/menu_add"
      android:showAsAction="ifRoom|withText"
      android:onClick="addItem"
        /&gt;
</code></pre>

<p>With the onClick calling my addItem void</p>

<pre><code>public void addItem(MenuItem menuItem) {

        String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();

        try {
            FileWriter filenew = new FileWriter(sdcard + "/test.txt");
            BufferedWriter bw = new BufferedWriter(filenew);
            bw.write(menuItem.toString());
            bw.close();
        } catch (IOException e) {
            //You'll need to add proper error handling here
        }

    }
</code></pre>

<p>At the moment menuItem.toString() understandably just returns the string 'Add' </p>

<p>How can I access the text contained in the EditText control so I can add that to the test.txt file?</p>
