package com.demo.mylibrary;

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

/**
 * 数据库辅助类
 */
public class DatabaseHelper extends SQLiteOpenHelper {
    private static final String CREATE_PAGE = "create table Page (id integer primary key autoincrement,UserId text,PageId text,PageStatus text,Previous text,FunnelId text,BeginTime text,EndTime text)";
    private static final String CREATE_BEHAVIOR = "create table Behavior (id integer primary key autoincrement,UserId text,EventId text,Value text,BeginTime text,EndTime text)";

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

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(CREATE_PAGE);
        sqLiteDatabase.execSQL(CREATE_BEHAVIOR);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        sqLiteDatabase.execSQL("drop table if exists Page");
        sqLiteDatabase.execSQL("drop table if exists Behavior");
        this.onCreate(sqLiteDatabase);
    }
}
