0

can you help me to understand what is the different between change the activity and rotate the screan?

I can persist the data when i rotate the screan but when i change to other activity and return the data is not persisting

can you help me?

  • How are you persisting the info? What is happening exactly? – Denis Jul 31 '17 at 22:25
  • i am persisting with two void , this work only for rotate public void onSaveInstanceState(Bundle estado) { // Save the user's current game state string = String.valueOf(textoexportar.getText()); estado.putString("cuenta",string); super.onSaveInstanceState(estado); // Always call the superclass so it can save the view hierarchy state } public void onRestoreInstanceState(Bundle estado){ super.onRestoreInstanceState(estado); string = estado.getString("cuenta"); textoexportar.setText(string); } – 29get4l Jul 31 '17 at 22:35
  • i have a button to go to other activity and when i return at the first the info that i save into the string is missing =( – 29get4l Jul 31 '17 at 22:42
  • Possible duplicate of [Saving Android Activity state using Save Instance State](https://stackoverflow.com/questions/151777/saving-android-activity-state-using-save-instance-state) – Denis Jul 31 '17 at 22:45
  • That a look at this question: https://stackoverflow.com/questions/151777/saving-android-activity-state-using-save-instance-state but basically the instance state is not the right way of persisting info. If you want to store the information through multiples uses take a look at https://developer.android.com/guide/topics/data/data-storage.html#pref – Denis Jul 31 '17 at 22:47
  • Thx denis for the quick answer, i am a little bit lost, i only want persist one variable string what do you recomend me?? , and why this way is working with the rotate and no with the change of activities??? many thx !!! – 29get4l Jul 31 '17 at 22:57
  • denis what do you thing if i create a class and i store with propertys in there? – 29get4l Jul 31 '17 at 23:14
  • Another class still wouldnt persist. I would recommend using the SharedPreferences. I wrote an answear for this here: https://stackoverflow.com/questions/45220436/entering-app-exactly-as-it-was-left/45222321#45222321 – Denis Jul 31 '17 at 23:30

0 Answers0