• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why oncreate doesn't run always

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is my db helper class



below is my main class



when i run this code 2nd time it doesn't run the OnCreate mehtod in the DBHandler class.why it doesn't run each time ?

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The lifecycle of activities is explained in extensive detail in the javadocs of the Activity class. I seem to recall pointing you to it more than once. If, after all these months of programming for Android, you still haven't internalized it, then, frankly, you're doing something wrong.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know oncreate called when activity initiated.But i have installed the all again.even then oncreate doesn't run.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think i found the answer.

http://stackoverflow.com/questions/21881992/when-is-sqliteopenhelper-oncreate-onupgrade-run

anyway Thanks ULF for your helping.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i have installed the all again.even then oncreate doesn't run.

That sounds very odd, not to say highly unlikely. Stopping an app (via the Settings) or uninstalling/reinstalling it will definitely cause an app to be terminated (and thus cause onCreate to be run the next time it is started). If you can reproduce that that is not happening for your app, then that would be a grave bug in Android.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, you were talking about DBHandler, not AndroidSQLiteTutorialActivity. That would have been very useful to have been mentioned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic