//Copyright (c) 2015 Shweta Agrawal 
//This source file is licensed under the "MIT License". 
//Please see the file COPYING in this distribution for license terms.
package com.contactmanager.home.assignmentreminder;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by home on 7/3/2015.
 */
public class Database {
    public static final String KEY_ROWID = "id";
    public static final String KEY_TITLE = "title";
    public static final String KEY_DUEDATE = "duedate";
    public static final String KEY_COURSE = "course";
    public static final String KEY_NOTES = "notes";
    private static final String TAG = "DBAdapter";
    private static final String DATABASE_NAME = "AssignmentsDB";
    private static final String DATABASE_TABLE = "assignments";
    private static final int DATABASE_VERSION = 2;
    private static final String DATABASE_CREATE = "create table if not exists assignments (id integer primary key autoincrement, title VARCHAR not null, duedate date, course VARCHAR, notes VARCHAR)";
    private final Context context;
    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;
    public Database(Context ctx)
    {
         this.context = ctx;
         DBHelper = new DatabaseHelper(context);
         }

             private static class DatabaseHelper extends SQLiteOpenHelper
     {
         DatabaseHelper(Context context)
         {
             super(context, DATABASE_NAME, null, DATABASE_VERSION);
             }

         @Override
         public void onCreate(SQLiteDatabase db)
         {
              try {
              db.execSQL(DATABASE_CREATE);
              } catch (SQLException e) {
              e.printStackTrace();
              }
              }
         @Override
          public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
          {
          Log.w(TAG, "Upgrading database from version " + oldVersion + " to " +
                  59 + newVersion + ", which will destroy all old data");
          db.execSQL("DROP TABLE IF EXISTS contacts");
          onCreate(db);
          }
          }
    //---opens the database---
    public Database open() throws SQLException
     {
         db = DBHelper.getWritableDatabase();
         return this;
         }

             //---closes the database---
             public void close()
     {
         DBHelper.close();
         }

             //---insert a record into the database---
             public long insertRecord(String title, String duedate, String course, String notes)
     {
         ContentValues initialValues = new ContentValues();
         initialValues.put(KEY_TITLE, title);
         initialValues.put(KEY_DUEDATE, duedate);
         initialValues.put(KEY_COURSE, course);
         initialValues.put(KEY_NOTES, notes);
         return db.insert(DATABASE_TABLE, null, initialValues);
         }

             //---deletes a particular record---
             public boolean deleteContact(long rowId)
     {
         return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0;
         }

             //---retrieves all the records---
             public Cursor getAllRecords()
     {
         return db.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
                         KEY_DUEDATE, KEY_COURSE, KEY_NOTES}, null, null, null, null, null);
         }

             //---retrieves a particular record---
             public Cursor getRecord(long rowId) throws SQLException
     {
         Cursor mCursor =
                 db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
                         KEY_TITLE, KEY_DUEDATE, KEY_COURSE, KEY_NOTES},
                 KEY_ROWID + "=" + rowId, null, null, null, null, null);
         if (mCursor != null) {
             mCursor.moveToFirst();
             }
         return mCursor;
         }

             //---updates a record---
             public boolean updateRecord(long rowId, String title, String duedate, String
                     course, String notes)
     {
         ContentValues args = new ContentValues();
         args.put(KEY_TITLE, title);
         args.put(KEY_DUEDATE, duedate);
         args.put(KEY_COURSE, course);
         args.put(KEY_NOTES, notes);
         return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0;
         }
     }



@@ -113,15 +113,15 @@
 ile 
-COPYING
+LICENSE
  in 

Update Database.java