question

Amazon Customer avatar image
Amazon Customer asked

Instance variables not saved after powering off Kindle

I'm a new developer, and I've just a problem with my first app. When I power off my Kindle Fire and then power it back, it no longer remembers the values of my instance variables (so the app starts all over from the beginning, instead of from its savedInstanceState). Do I need to explicitly instruct the app to save the values -- and if so, in which method?
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon Customer avatar image
Amazon Customer answered
Okay, I solved my own problem by storing the instance variables in a SharedPreferences object, per an Android help page. Still not sure why the static instance variables were not already being saved by the default onPause and onStop methods, but this solved my issue. Figured I would post in case anyone else was having the same problem.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon Customer avatar image
Amazon Customer answered
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon Customer avatar image
Amazon Customer answered
Ah, I see. According to the Android documentation, "By default, the system uses the Bundle instance state to save information about each View object in your activity layout (such as the text value entered into an EditText object)... However, your activity might have more state information that you'd like to restore, such as member variables that track the user's progress in the activity.... To save additional data about the activity state, you must override the onSaveInstanceState() callback method." http://developer.android.com/training/basics/activity-lifecycle/recreating.html
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

callabud avatar image
callabud answered
can you get any thing in that web?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

callabud avatar image
callabud answered
every thing, sorry
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.