package com.cygnusa.hyperm.util;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
    Context con;

    public DatabaseHelper(Context context, String name, CursorFactory factory,
                          int version) {
        super(context, name, factory, version);
        this.con = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        try {
            db.execSQL("create table if not exists session(user text)");
            db.execSQL("create table if not exists banner(banner text)");

            db.execSQL("create table if not exists training(id integer primary key autoincrement," + "training text)");

            db.execSQL("create table if not exists training_category(training_category text)");
            db.execSQL("create table if not exists topic(topic text,category_id text,topic_id text)");
            db.execSQL("create table if not exists topic_content(topic_content text,category_id text,topic_id text,content_id text)");

            db.execSQL("create table if not exists assessment(id integer primary key autoincrement," +
                    "training_id text,category_id text,assessment_id text,assessment text)");

            db.execSQL("create table if not exists assessment_question(id integer primary key autoincrement," +
                    "training_id text,category_id text,assessment_id text,assessment_question text)");

            db.execSQL("create table if not exists assessment_answer(id integer primary key autoincrement," +
                    "training_id text,category_id text,assessment_id text,assessment_answer text,error text)");

            db.execSQL("create table if not exists notifications(notifications text)");
            db.execSQL("create table if not exists notification_readed(notification_readed text)");
            db.execSQL("create table if not exists notification_deleted(notification_deleted text)");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int ov, int nv) {
        onCreate(db);

    }

}
