Search code examples
androidreferencesettext

How would i pass reference value(basic)?


In my FormActivity, there are two EditText's:

EditText editname = (EditText) findViewById(R.id.idname);
EditText editage  = (EditText) findViewById(R.id.idage);

then when user clicks:

String name = editname.getText().toString();
int age = parseInt(editage.getText().toString());

now my purpose is...

next time i visit the page(FormActivity), the last value of the editname and edit age is still there

thanks :)


Solution

  • Are you trying to prepopulate those fields? If so, you can store them in the Bundle for your Activity and then restore them in the onResume() method. You can also store them on your device's flash memory, since your application is allocated some memory for storing configuration, and you could read them back out of local storage when your application starts