السلام عليكم شباب

عندي مشكله في الاندوريد

عملت كود لحفظ البيانات بعد ما يعمل المستخدم قلب للشاشه او اي حدث يفقد البيانات

ربما هناك مشكله في الكود

public class Areas extends AppCompatActivity {

double area = 0;
TextView text;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_areas);



    Spinner sp=findViewById(R.id.spinner2);
    EditText width=findViewById(R.id.Areas_width_1);
    EditText hight=findViewById(R.id.Areas_hight_1);
    EditText base=findViewById(R.id.Areas_base_2);
    EditText radius=findViewById(R.id.Areas_Radius);
    EditText hight2=findViewById(R.id.Areas_hight_2);
    text=findViewById(R.id.textView);
    Button calculate=findViewById(R.id.Calcalute);

    sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position){

                case 0:
                    width.setVisibility(View.VISIBLE);
                    hight.setVisibility(View.VISIBLE);
                    base.setVisibility(View.GONE);
                    hight2.setVisibility(View.GONE);
                    radius.setVisibility(View.GONE);
                    break;
                case 1:
                    width.setVisibility(View.GONE);
                    hight.setVisibility(View.GONE);
                    base.setVisibility(View.GONE);
                    hight2.setVisibility(View.GONE);
                    radius.setVisibility(View.VISIBLE);
                    break;
                case 2:
                    width.setVisibility(View.GONE);
                    hight.setVisibility(View.GONE);
                    base.setVisibility(View.VISIBLE);
                    hight2.setVisibility(View.VISIBLE);
                    radius.setVisibility(View.GONE);
                    break;


            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });


    calculate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                int index = sp.getSelectedItemPosition();
                switch (index) {
                    case 0:
                        double reac_width = Double.parseDouble(width.getText().toString());
                        double reac_hieght = Double.parseDouble(hight.getText().toString());

                        area = reac_hieght * reac_width;
                        break;
                    case 1:
                        double cir_radius = Double.parseDouble(radius.getText().toString());
                        area = Math.PI * Math.pow(cir_radius, 2);
                        break;
                    case 2:
                        double tri_base = Double.parseDouble(base.getText().toString());
                        double tri_hieght = Double.parseDouble(hight2.getText().toString());
                        area = tri_hieght * tri_base;
                        break;

                }
                text.setText(area + "");
            }
            catch (Exception e){
                text.setText(R.string.shaa_asd);
            }

        }
    });




}


@Override
public void onSaveInstanceState(@NonNull Bundle outState, @NonNull PersistableBundle outPersistentState) {
    super.onSaveInstanceState(outState, outPersistentState);
    outState.putString("Asd",area+"");

}

@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    String b=savedInstanceState.getString("Asd");
    text.setText(b);
}

}