Android Basics – Learn how to use the SQLiteOpenHelper class to setup App Database

SQLiteOpenHelper enables you to create and manage the database. To understand this better create a new class called SurveyDBHelper and extend this class.

In this class you will write the code to create the database tables needed for the Survey App.

public class SurveyDBHelper extends SQLiteOpenHelper

The Survey App will store the information in a survey table. The survey table will store – name, email and age.

It’s an Android convention to call your primary key columns _id.

Following are the data types that can be used

INTEGER – Numbers
TEXT – Character
REAL – Floating Points
NUMERIC – Booleans and Date
BLOB – Binary large object

Keeping this in mind you can use the CREATE TABLE SQL statement to create a new table.

@Override
public void onCreate(SQLiteDatabase db) {
 db.execSQL("CREATE TABLE "+SURVEY_TABLE+" (_id INTEGER PRIMARY KEY AUTOINCREMENT, "
 +SURVEY_TABLE_NAME_COLUMN+" TEXT, "
 +SURVEY_TABLE_EMAIL_COLUMN+" TEXT, "
 +SURVEY_TABLE_AGE_COLUMN+" INTEGER);"
 );
}

Follow the video to understand this better. 
Also the source code is available here for reference.