I am new to Android and I have to create an application where I need to use a SQLite database. I am not so well equipped with the SQLite.
Could you tell me what the purpose and use of the SQLiteOpenHelper
class, and provide a simple database creation and insertion example?
This question is related to
android
database
sqlite
sqliteopenhelper
Using Helper class you can access SQLite Database and can perform the various operations on it by overriding the onCreate() and onUpgrade() methods.
http://technologyguid.com/android-sqlite-database-app-example/
The following Links my help you
Database Helper Class:
A helper class to manage database creation and version management.
You create a subclass implementing onCreate(SQLiteDatabase)
, onUpgrade(SQLiteDatabase, int, int)
and optionally onOpen(SQLiteDatabase)
, and this class takes care of opening the database if it exists, creating it if it does not, and upgrading it as necessary. Transactions are used to make sure the database is always in a sensible state.
This class makes it easy for ContentProvider
implementations to defer opening and upgrading the database until first use, to avoid blocking application startup with long-running database upgrades.
You need more refer this link Sqlite Helper
The DBHelper class is what handles the opening and closing of sqlite databases as well sa creation and updating, and a decent article on how it all works is here. When I started android it was very useful (however I've been objective-c lately, and forgotten most of it to be any use.
Source: Stackoverflow.com