package com.example.appli_calendar04;

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

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


public class Database extends SQLiteOpenHelper 
{
    private static final String DATABASE_NAMES = "events01";
    private static final int DATABASE_VERSION = 3;
    
    public static final String KEY_ID = "_id";
    public static final String COL_NAME = "name";
    public static final String COL_FROMDATE = "from_date";
	public static final String COL_TODATE = "to_date";
	public static final String COL_DATETIME = "datetime";
	public static final String COL_STATUS = "status";
	public static final String COL_CREATEDTIME = "created_time";
	public static final String COL_MODIFIEDTIME = "modified_time";
	public static final String COL_RULE = "rule";
	public static final String COL_INTERVAL = "interval";
	public static final String COL_SOUND = "sound";
	public static final String COL_INFO = "info";
	public static final String COL_CREATED_AT = "created_at";
    
	public  static final String NEW_CREATE_TABLE = "CREATE TABLE "
            + DATABASE_NAMES + "(" 
    		+ KEY_ID + " INTEGER PRIMARY KEY,"
    		+ COL_NAME + " TEXT," 
    		+ COL_FROMDATE + " DATE," 
    		+ COL_TODATE + " DATE," 
    		+ COL_DATETIME + " INTEGER," 
    		+ COL_STATUS + " TEXT," 
            + COL_CREATEDTIME + " INTEGER," 
            + COL_MODIFIEDTIME + " INTEGER,"
            + COL_RULE + " TEXT," 
            + COL_INTERVAL + " TEXT," 
            + COL_SOUND + " INTEGER,"
            + COL_INFO + " TEXT," 
            + COL_CREATED_AT + " DATETIME" + ")";
    
    public Database(Context context) {
        super(context, DATABASE_NAMES, null, DATABASE_VERSION);
    }
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		
		String req = "CREATE TABLE events ( `_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `message` TEXT NOT NULL, `reminder` TEXT NOT NULL, `end` TEXT )";
		  db.execSQL(req);
		
		
		
	}
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
		 db.execSQL("DROP TABLE IF EXISTS "+ DATABASE_NAMES);
	        onCreate(db);
		
	}
}