Final answer:
To prevent data loss, you need to save and restore the value of EditTexts when the device rotates.
Step-by-step explanation:
When the device rotates, the activity is destroyed and recreated. This means that if you don't save and restore the value of EditTexts, the user's input will be lost.
To save the value of EditTexts, you can use the onSaveInstanceState() method to save the data into a Bundle and then restore it in the onCreate() or onRestoreInstanceState() method of the activity.
Here's an example of how you can save/restore the value of an EditText:
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("editTextValue", editText.getText().toString());
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
String value = savedInstanceState.getString("editTextValue");
editText.setText(value);
}