How come when I need to access a variable or set one in another Activity it resets it when I go
new MainActivity()
for example, I get an input in SecondActivity and want to set a Variable in MainActivity
String input1 = editText.getText().toString();
int input=Integer.parseInt(input1);
MainActivity ma = new MainActivity();
ma.setTableNumber(input);
but when I go to get it in ThirdActivity it is 0 again
int a = Interget.toString(new MainActivity().getTableNumber());
is there a way to avoid having to go new MainActivity()
every time?
this is how I go from MainActivity to SecondActivity btw
Intent loadTableNumberScreen = new Intent(MainActivity.this, TableNumber.class);
startActivity(loadTableNumberScreen);
If that helps at all