OnClickListener [Eclipse]
===

I currently have this page in my Android App:
http://i50.tinypic.com/iwhci1.png

I am wanting to pass the data added into these fields to a .txt file stored on the device.

My XML code is below:




    <Button
    android:id="@+id/Button02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/btn2" />
    <ScrollView android:layout_width="match_parent" android:id="@+id/scrollView1" android:layout_height="wrap_content">
    <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal">
    <TextView android:text="Please insert details below to confirm you have completed and understood the app" android:id="@+id/textView1" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_gravity="center_horizontal">
    </TextView>
    </LinearLayout>
    </ScrollView>
    		<EditText
    		    android:id="@+id/editText1"
    		    android:layout_width="match_parent"
    		    android:layout_height="wrap_content"
    		    android:ems="10"
    		    android:text="Forename" >
    
    		    <requestFocus />
    		</EditText>
    
    		<EditText
    		    android:id="@+id/editText2"
    		    android:layout_width="match_parent"
    		    android:layout_height="wrap_content"
    		    android:ems="10"
    		    android:text="Surname" />
    
    		<EditText
    		    android:id="@+id/editText3"
    		    android:layout_width="match_parent"
    		    android:layout_height="wrap_content"
    		    android:ems="10"
    		    android:inputType="number"
    		    android:text="Staff ID" />
    
    		<Button
    		    android:id="@+id/buttonformdata"
    		    android:layout_width="wrap_content"
    		    android:layout_height="wrap_content"
    		    android:text="Submit" />
    </LinearLayout>




I want the data entered into editText1, editText2 and editText3 to be sent and stored into a .txt file on the device. I have been instructed by someone that i can do this by creating a onlicklistener to pass the data between the XML page and my text file by using the following code with an onclicklistener:

    try{

    FileOutputStream fout = openFileOutput(“yourfile.txt”,MODE_PRIVATE);

    OutputStreamWriter osw = new OutputStreamWriter(fOut);

    osw.write(editText1.getText().toString()+" ");
    osw.write(editText2.getText().toString()+" ");
    osw.write(editText3.getText().toString()+" ");

    osw.close();

    fout.close();

    }catch(Exception e){

    //do the exception handling
    }


But how do i get an onclicklistener to do this? My only previous expereince with onclicklisteners is to change between XML files using buttons using view? How do i get this to work? If the code for my project is needed i can upload it, if this will make it easier.

Thanks.
