I shared the preference value A after I run a calculation with B you can write directly the result of AB in the shared preference by replacing A with the new value
public class Stats extends Activity {
private final static String MY_PREFERENCES = "MyPref";
private final static String GIORNISPETT = "giornispett";
public void indietro (View view){
}
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = getSharedPreferences(MY_PREFERENCES, Context.MODE_PRIVATE);
int giornispett = Integer.parseInt(prefs.getString(GIORNISPETT, "24"));
super.onCreate(savedInstanceState);
setContentView(R.layout.stats);
Intent intent=getIntent();
String trn=getPackageName();
int Giorni=intent.getIntExtra(trn+".Intgiorni", 0);
int Giorniresidui=giornispett-Giorni;
TextView tvgiorni=(TextView)findViewById(R.id.txtgiorni);
tvgiorni.append(+Giorni+"");
TextView tvGiorni_rest=(TextView)findViewById(R.id.txtGiorni_rest);
tvGiorni_rest.setText(""+Giorniresidue);
}
}