// Path: app/src/main/java/com/YC2010/MyClass/model/Reminder_item.java
// public class Reminder_item {
//     // variables
//     String id;
//     String title;
//     String location;
//     GregorianCalendar mClaendar;
//     String type;
// 
//     // type:
//     // "c"      customized
//     // "e"      exams
//     // "fb"     facebook events
//     // "d"      important dates
// 
//     // constructor
//     public Reminder_item(){
//         // empty
//     }
// 
//     // Ctor for all
//     public Reminder_item(String id, String title, String location, int year, int month, int day, int hour, int minute, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar(year,month,day,hour,minute);
//         this.type = type;
//     }
// 
//     // ctor for no hout and minute
//     public Reminder_item(String id, String title, String location, int year, int month, int day, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar(year,month,day);
//         this.type = type;
//     }
// 
//     //Ctor for unix time
//     public Reminder_item(String id, String title, String location, long unix_time, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar();
//         this.mClaendar.setTimeInMillis(unix_time);
//         this.type = type;
//     }
// 
//     public String get_id(){
//         return this.id;
//     }
// 
//     public String get_title(){
//         return this.title;
//     }
// 
//     public String get_location(){
//         return this.location;
//     }
// 
//     public long get_unix_time(){
//         return this.mClaendar.getTimeInMillis();
//     }
// 
//     public String get_type(){ return this.type;}
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import com.YC2010.MyClass.model.Reminder_item;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
package com.YC2010.MyClass.data;




/**
 * Created by Jason on 2015-06-02.
 */
public class ReminderDBHandler extends SQLiteOpenHelper {
    // DB Version
    private static final int DATABASE_VERSION = 3;

    // DB Name
    private static final String DATABASE_NAME = "ReminderManager";

    // Table name
    private static final String TABLE_REMINDERS = "reminders";

    // TABLE_REMINDERS Columns names                            // columnIndex
    private static final String KEY_ID = "id";                  //      0
    private static final String KEY_TITLE = "title";            //      1
    private static final String KEY_LOCATION = "location";      //      2
    private static final String KEY_UNIX_TIME = "Unix_time";    //      3
    private static final String KEY_TYPE = "type";              //      4

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

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d("ReminderDBHandler", "onCreate");
        String CREATE_TABLE = "CREATE TABLE " + TABLE_REMINDERS + "("
                + KEY_ID + " STRING PRIMARY KEY," + KEY_TITLE + " TEXT,"
                + KEY_LOCATION + " TEXT," + KEY_UNIX_TIME + " TEXT,"
                + KEY_TYPE + " TEXT" + ")";
        db.execSQL(CREATE_TABLE);
    }

    // Upgrading database
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Drop older table if existed
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_REMINDERS);

        // Create tables again
        onCreate(db);
    }

    /**
     * All CRUD(Create, Read, Update, Delete) Operations
     */

    // Adding new Reminder
// Path: app/src/main/java/com/YC2010/MyClass/model/Reminder_item.java
// public class Reminder_item {
//     // variables
//     String id;
//     String title;
//     String location;
//     GregorianCalendar mClaendar;
//     String type;
// 
//     // type:
//     // "c"      customized
//     // "e"      exams
//     // "fb"     facebook events
//     // "d"      important dates
// 
//     // constructor
//     public Reminder_item(){
//         // empty
//     }
// 
//     // Ctor for all
//     public Reminder_item(String id, String title, String location, int year, int month, int day, int hour, int minute, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar(year,month,day,hour,minute);
//         this.type = type;
//     }
// 
//     // ctor for no hout and minute
//     public Reminder_item(String id, String title, String location, int year, int month, int day, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar(year,month,day);
//         this.type = type;
//     }
// 
//     //Ctor for unix time
//     public Reminder_item(String id, String title, String location, long unix_time, String type){
//         this.id = id;
//         this.title = title;
//         this.location = location;
//         this.mClaendar = new GregorianCalendar();
//         this.mClaendar.setTimeInMillis(unix_time);
//         this.type = type;
//     }
// 
//     public String get_id(){
//         return this.id;
//     }
// 
//     public String get_title(){
//         return this.title;
//     }
// 
//     public String get_location(){
//         return this.location;
//     }
// 
//     public long get_unix_time(){
//         return this.mClaendar.getTimeInMillis();
//     }
// 
//     public String get_type(){ return this.type;}
// }


// Path: app/src/main/java/com/YC2010/MyClass/data/ReminderDBHandler.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import com.YC2010.MyClass.model.Reminder_item;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

package com.YC2010.MyClass.data;




/**
 * Created by Jason on 2015-06-02.
 */
public class ReminderDBHandler extends SQLiteOpenHelper {
    // DB Version
    private static final int DATABASE_VERSION = 3;

    // DB Name
    private static final String DATABASE_NAME = "ReminderManager";

    // Table name
    private static final String TABLE_REMINDERS = "reminders";

    // TABLE_REMINDERS Columns names                            // columnIndex
    private static final String KEY_ID = "id";                  //      0
    private static final String KEY_TITLE = "title";            //      1
    private static final String KEY_LOCATION = "location";      //      2
    private static final String KEY_UNIX_TIME = "Unix_time";    //      3
    private static final String KEY_TYPE = "type";              //      4

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

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d("ReminderDBHandler", "onCreate");
        String CREATE_TABLE = "CREATE TABLE " + TABLE_REMINDERS + "("
                + KEY_ID + " STRING PRIMARY KEY," + KEY_TITLE + " TEXT,"
                + KEY_LOCATION + " TEXT," + KEY_UNIX_TIME + " TEXT,"
                + KEY_TYPE + " TEXT" + ")";
        db.execSQL(CREATE_TABLE);
    }

    // Upgrading database
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Drop older table if existed
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_REMINDERS);

        // Create tables again
        onCreate(db);
    }

    /**
     * All CRUD(Create, Read, Update, Delete) Operations
     */

    // Adding new Reminder
    public void addReminder(Reminder_item reminder) {