package com.cloudskol.moviedroid.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author tham
 */
public class MovieDbHelper extends SQLiteOpenHelper {
    private static final String LOG_TAG = MovieDbHelper.class.getSimpleName();

    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "Moviedroid.db";

    public MovieDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    private String buildCreateTableQuery() {
        final StringBuilder builder = new StringBuilder();
        builder.append("CREATE TABLE ");
        builder.append(MovieContract.MovieEntry.TABLE_NAME);

        Log.v(LOG_TAG, "Create table query: " + builder.toString());
        return builder.toString();
    }

    private String buildDropTableQuery() {
        return "DROP TABLE IF EXISTS " + MovieContract.MovieEntry.TABLE_NAME;
    }
}

@@ -634,24 +634,68 @@
 abase db) %7B%0A
+        db.execSQL(buildCreateTableQuery());
 %0A    %7D%0A%0A    
@@ -787,219 +787,805 @@
 ) %7B%0A
-%0A    %7D%0A%0A    private String buildCreateTableQuery() %7B%0A        final StringBuilder builder = new StringBuilder();%0A        builder.append(%22CREATE TABLE %22);%0A        builder.append(MovieContract.MovieEntry.TABLE_NAME
+        db.execSQL(buildDropTableQuery());%0A        onCreate(db);%0A    %7D%0A%0A    @Override%0A    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        onUpgrade(db, oldVersion, newVersion);%0A    %7D%0A%0A    private String buildCreateTableQuery() %7B%0A        final StringBuilder builder = new StringBuilder();%0A        builder.append(%22CREATE TABLE %22);%0A        builder.append(MovieContract.MovieEntry.TABLE_NAME);%0A        builder.append(%22 (%22);%0A        builder.append(MovieContract.MovieEntry._ID + %22 INTEGER PRIMARY KEY, %22);%0A        builder.append(MovieContract.MovieEntry.COLUMN_MOVIE_ID + %22 INTEGER, %22);%0A        builder.append(MovieContract.MovieEntry.COLUMN_TITLE + %22 TEXT, %22);%0A        builder.append(MovieContract.MovieEntry.COLUMN_OVERVIEW + %22 TEXT%22);%0A        builder.append(%22 )%22
 );%0A%0A

Create and drop schema changes are done