-2

Just want to know the moment database is created and checked for upgrade.
I dont call create database manualy and leave it to SQLiteOpenHelper. But I dont know, when and how clasees that extend SQLiteOpenHelper are called. Is it before Application onCreate() or after?

Yarh
  • 4,459
  • 5
  • 45
  • 95

2 Answers2

0

Databases for an application are created when you create them. Specifically when the application is installed it calls onCreate().

You can read more here: http://developer.android.com/training/basics/data-storage/databases.html

Read the documentation @ http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#onCreate(android.database.sqlite.SQLiteDatabase)

Excerpt

public abstract void onCreate (SQLiteDatabase db)

Added in API level 1
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen.

Parameters
db  The database.
JoxTraex
  • 13,423
  • 6
  • 32
  • 45
0

It's crated when you make call to SQLiteOpenHelper::getReadableDatabase or SQLiteOpenHelper::getWritableDatabase.

Just check the docs, it's there:

SQLiteOpenHelper::SQLiteOpenHelper(...)

Create a helper object to create, open, and/or manage a database. This method always returns very quickly. The database is not actually created or opened until one of getWritableDatabase() or getReadableDatabase() is called.

pelotasplus
  • 9,852
  • 1
  • 35
  • 37