-2
searchField.getText()

I want to store data of a EditText field in a variable. I know it returns string data but when I tried to store that in string type variable that didn't work.

As in java variables declared according to the class name,

I tried that way too. I tried EditText varibleName = searchField.getText(); But didn't work.

can anyone explain why it didn't work and what should be the correct data type to store it?

I need an explanation how does it works. I mean What if I don't convert it to string. and What if I want to store it as row.

Peter
  • 31
  • 6

2 Answers2

1

you can simply use

String var = searchField.getText().toString();
Deepak Kumar
  • 1,035
  • 10
  • 18
0

You need to convert it to String

String.valueOf(searchField.getText())
Fatimah Mohmmed
  • 147
  • 2
  • 18