0

I have been searching on internet ı have found these informations: OnCreate() method is called when database is opened or created... Okey but how is this method called ?by whom? Activity class has OnCreate method also, are these two OnCreate methods similar ?if so what makes them similar? Activities OnCreate method is called by OS? but how? What papers should ı read? I know when these methods called ı want to know how. Thank you.

Burak Karasoy
  • 1,682
  • 2
  • 21
  • 33

2 Answers2

0

Okey but how is this method called ?by whom?

It is called by SQLiteOpenHelper itself, in response to a call to getReadableDatabase() and/or getWriteableDatabase(). You can see this in the source code to SQLiteOpenHelper.

Activity class has OnCreate method also, are these two OnCreate methods similar ?

Not really.

Activities OnCreate method is called by OS? but how?

It is called by Activity itself, as part of the startup process. Starting up an Activity is rather complicated, but you are welcome to review the ~6000 lines of the Activity source code if you like.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for help. I was confused about how can getWriteableDatabase()or getReadableDatabase call a method of sublass which was overrided,I figured it out also. – Burak Karasoy Mar 28 '15 at 22:22
0

Activity is a class already build in Android SDK. onCreate(), onStart() etc are the methods in it. When you extend a class with Activity that becomes the User interface related class and it follows the activity lifecycle to perform UI operations. The lifecycle is start with onCreate() and ends with onDestroy(). To better understand please read the developer guidelines Activity here

The Database is completely different thing than activity. The SQLiteOpenHelper is also a class in Android related to database operations. So whenever you create and object of database class the onCreate() called by itself. The SQLiteOpenHelper Guidelines

tausif
  • 56
  • 1
  • 9