I'm having a hard time wrapping my head around handling the Activity Lifecycle...

Posted by kefs on Stack Overflow See other posts from Stack Overflow or by kefs
Published on 2010-05-30T00:55:24Z Indexed on 2010/05/30 1:02 UTC
Read the original article Hit count: 207

Filed under:
|

So it seems i've created a fatal flaw and coded an app before understanding/handling rotation/lifecycle events.. Currently, all of my code is in onCreate of each activity. I've read a lot of lifecycle tutorials online, including the official dev guide info, but i'm still having an almost unbelievably hard time trying to wrap my head around the rotation/lifecycle events/methods and when to use them correctly.

For example, my app currently has an activity that opens the db, inserts a record, then closes the db.. if i rotate my screen on this activity, the data is re-entered into the db. Using the available lifecycle events (onPause(), onResume(), etc..), how would I prevent this db call from happening again? Would I have to pass a variable through the state saying that the db call has been done, and not to do it again?

Thanks in advance..

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sdk