How to restore the instance state

RonNYCRonNYC Member ✭✭✭

I want to preserve program data when the user runs another program. So if the user puts, say, her name into a text box and then goes to another app, when he comes back to the program I want the name in the text box.

This works during debug. Here's my code:

protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);

and here's how I save the instance data:

public void onSaveInstanceState(Bundle savedInstanceState)
{
//super.onSaveInstanceState(savedInstanceState);
// Save UI state changes to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
// killed and restarted.

        savedInstanceState.PutString("txtName", txtName.Text);

etc.

Again, this works perfectly (it seems to me) in debug but not in release mode.

Why?

RON

Tagged:

Best Answer

Answers

Sign In or Register to comment.