I hope you can support me with this doubt that does not let me move forward with the app I'm doing. How can I store two data on the screen2 from the screen1 permanently, so that when I go to another screen and return I still have the same data. For this I have implemented this code. But he keeps losing them:
final SharedPreferences prefe=this.getActivity().getSharedPreferences("datos", Context.MODE_PRIVATE);
String idusu= getArguments()!=null ? getArguments().getString("idusu"):"SIN DATOS";
String gasto= getArguments()!=null ? getArguments().getString("gasto"):"SIN DATOS";
SharedPreferences.Editor editor = prefe.edit();//SE crea un objeto de la clase Editor,obtengo la referencia del objeto de la clase SharedPreferences
editor.putString("idusu", idusu);//Mediante el método putString almacenamos en idideta el valor del String cargado en el EditText
editor.commit();//metodo commit de la clase editor hace que el dato quede almacenado en forma permanente en el archivo de preferencias para k caundo arranq la aplicación se recupere el último idideta ingresado
//Toast.makeText(getContext(), nombre, Toast.LENGTH_SHORT).show();
SharedPreferences.Editor editor2 = prefe.edit();
editor2.putString("gasto", gasto);
editor2.commit();
//Toast.makeText(getContext(), gasto2, Toast.LENGTH_SHORT).show();
String nombre = prefe.getString("idusu", "valor nombre");
String gasto2 = prefe.getString("gasto", "valor gasto2");