Is sharedpreferences indicated to save the application status?

Asked

Viewed 28 times

0

I’ve searched several gringo sites but found nothing, including here.

I have a problem in the application that whenever the user minimizes it and uses the mobile phone for something else on cell phones with little memory it gets erased for new data, so when the application is opened again (it was in the background) it always error and closes why an object is not saved, was in memory and after erasing it gets null by making the error happen.

Is my question advisable to do this with Sharedpreferences? Because I always see it being used with strings, int, bollean etc. or there is another more efficient method?

  • For this purpose it is normal to use the Bundle passed to the method onSaveInstanceState().

  • This can be of great help, I will search here how to use, Rigadão!

  • A doubt: To save it enters the [ onSaveInstanceState(Bundle outstate)] and to reload?

  • In the onCreate(), as explained there.

  • Yes, but in the app Mainactivity does not pass again onCreate, so I put onRestart

  • If the Activity is not recreated (onCreate() called) then the problem is another. I suggest you ask another question, code and error log, and explain exactly what’s happening.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.