I have an EditText field and I want to save the Text in it by pressing a button I tried to do it using the following code but the string remains as null
public void Botao (View view) {
setContentView(R.layout.content_main_menu);
EditText valor = (EditText) findViewById(R.id.ValorEdit);
String ValorF = valor.getText().toString()
Apparently the program is only receiving the previous state of EditText and not the typed text.