Hi,

The variable "bodyText"  in your code isn't a String.  It is an object
of EditText class.

You should get the text of an EditText view by:
String str = bodyText.getText();

That should help.


On Jan 27, 7:14 pm, André <pha...@hotmail.com> wrote:
> I tried that now but get the same problem.
>
> here is a screen shot of it:
>
> http://www.andreborud.com/android/android-problem-2.jpg
>
> André
>
> On Jan 27, 5:39 pm, Justin Anderson <janderson....@gmail.com> wrote:
>
>
>
> > Why are you using the final keyword?  I think that is the source of your
> > problem.  Remove that and I would be that everything will work out.
>
> > In java, "final" is more-or-less equivalent to "const" in c++.  Since you
> > are setting this variable every time a button is clicked I don't think you
> > want to set this to final.
>
> > I am curious though... what exactly is the error that you are getting?
>
> > ----------------------------------------------------------------------
> > There are only 10 types of people in the world...
> > Those who know binary and those who don't.
> > ----------------------------------------------------------------------
>
> > On Wed, Jan 27, 2010 at 9:26 AM, André <pha...@hotmail.com> wrote:
> > > Hello,
>
> > > I'm sure there has been a lot of questions like this here already. But
> > > I haven't been able to find an answer to my question is. I'm still
> > > very new to this so it's probably something very simple.
> > > What I am trying is to save text from a edittext window, it works fine
> > > if I have a pre-written text. Any suggestion on how I should make this
> > > work?
>
> > > Bellow you can see what I have tried! The row with the stars is what
> > > eclipse doesn't accept.
>
> > > private EditText bodyText;
>
> > >   �...@override
> > >    public void onCreate(Bundle savedInstanceState) {
> > >        super.onCreate(savedInstanceState);
> > >        setContentView(R.layout.main);
>
> > >        bodyText = (EditText) findViewById(R.id.body);
> > >        Button confirmButton = (Button) findViewById(R.id.confirm);
> > >        confirmButton.setOnClickListener(new View.OnClickListener() {
>
> > >                public void onClick(View view) {
> > >                        try {
> > >                            final String TESTSTRING = new String(bodyText);
>
> > > ***************************************************************************
> > >  *****
>
> > >                            FileOutputStream fOut =
> > > openFileOutput("samplefile.txt",
> > > MODE_WORLD_READABLE);
> > >                            OutputStreamWriter osw = new
> > > OutputStreamWriter(fOut);
>
> > >                            osw.write(TESTSTRING);
>
> > >                            osw.flush();
> > >                            osw.close();
>
> > >                        } catch (IOException ioe) {
> > >                            ioe.printStackTrace();
> > >                        }
> > >                }
>
> > >            });
> > >        }
> > > }
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Beginners" group.
>
> > > NEW! Try asking and tagging your question on Stack Overflow at
> > >http://stackoverflow.com/questions/tagged/android
>
> > > To unsubscribe from this group, send email to
> > > android-beginners+unsubscr...@googlegroups.com<android-beginners%2Bunsubscr
> > >  i...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-beginners?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to