android.database.sqlite.SQLiteOpenHelper
A helper class to manage database creation and version management.
See the Notepad ContentProvider sample for example code.
Summary
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
SQLiteOpenHelper()
Public Methods
public
abstract
void
onCreate(SQLiteDatabase db)
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.
Called when the database has been opened.
public
abstract
void
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
Called when the database needs to be upgraded. The implementation
should use this method to drop tables, add tables, or do anything else it
needs to upgrade to the new database.
Parameters
| db
| The database. |
| oldVersion
| The old database version. |
| newVersion
| The new database version.
|
Parameters
| context
| A context to use to open or create the database. |
| name
| The name of the database to open. |
| factory
| An optional factory class that is called to instantiate a cursor
when the database is opened. |
| newVersion
| The version of the database to open. If this is a new version (that
is, newVersion is > the existing version number), then onUpgrade() will
be called, and the implementation has the option to update the database. |
Returns
- Returns a SQLiteDatabase to use.