Thursday, October 7, 2010

SQLiteOpenHelper Vs SQLiteDatabase

SQLite is the cross platform Database Engine available for Android. It is an Open Source Database which requires very little amount of memory at runtime (typically less than 250 Kb).

We indeed have two classes for SQLite Database access in Android. 

  1. SQLiteOpenHelper
  2. SQLiteDatabase

Which should we use in our application?

SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks. More specifically SQLiteDatabase provides the insert(), update() and delete() methods.

SQLiteOpenHelper provides utilities to simplify the tasks of creating and initialising the database if it's not already created. In simple, it is a helper class to manage database creation and version management. SQLiteOpenHelper provides the methods getReadableDatabase() and getWriteableDatabase() to get access to an SQLiteDatabase object either in read or write mode.

It is upto the user to decide upon the Class to use within the application.