package com.zxhl.cms.db;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by gaoleichao on 2018/10/29.
 */
class DataHelper extends SQLiteOpenHelper {

    DataHelper(Context context) {
        this(context, DBConfig.DB_NAME, null, DBConfig.DB_VERSION);
    }

    private DataHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public DataHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int
            version, DatabaseErrorHandler errorHandler) {
        super(context, name, factory, version, errorHandler);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DBConfig.CREATE_CLICK_AD_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_WATCH_AD_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_NEWS_OR_AD_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_NEWS_TAB_LIST_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_STEP_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_USERCENTER_SETTING_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_USERCENTER_APLI_TABLE_SQL);
        db.execSQL(DBConfig.CREATE_NEWS_READ_HISTORY_TABLE_SQL);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
//        //数据库升级

    }
}