// Path: DataManagement/app/src/main/java/qa/edu/qu/cse/cmps312/datamanagement/SQLHelper/DatabaseOpenHelper.java
// public class DatabaseOpenHelper extends SQLiteOpenHelper {
// 
//     public final static String TABLE_NAME = "scientists";
//     public final static String SCIENTIST_NAME = "name";
//     final static String _ID = "_id";
//     public final static String[] columns = { _ID, SCIENTIST_NAME };
// 
//     final private static String CREATE_CMD =
// 
//             "CREATE TABLE scientists (" + _ID
//                     + " INTEGER PRIMARY KEY AUTOINCREMENT, "
//                     + SCIENTIST_NAME + " TEXT NOT NULL)";
// 
//     final private static String NAME = "scientists_db";
//     final private static Integer VERSION = 1;
//     final private Context mContext;
// 
//     public DatabaseOpenHelper(Context context) {
//         super(context, NAME, null, VERSION);
//         this.mContext = context;
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase db) {
//         db.execSQL(CREATE_CMD);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         // N/A
//     }
// 
//     public void deleteDatabase() {
//         mContext.deleteDatabase(NAME);
//     }
// }


import android.content.ContentValues;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import qa.edu.qu.cse.cmps312.datamanagement.SQLHelper.DatabaseOpenHelper;

                // execute database operations
                fix();

                // Redisplay data
                Cursor c = readScientists();
                mAdapter.changeCursor(c);
                mAdapter.notifyDataSetChanged();
            }
        });

    }

    // Insert several scientists records
    private void insertScientists() {

        ContentValues values = new ContentValues();

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Omar Al-Khayyam");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Al-Farabi");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Ibn Rushd");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Shakira");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

// Path: DataManagement/app/src/main/java/qa/edu/qu/cse/cmps312/datamanagement/SQLHelper/DatabaseOpenHelper.java
// public class DatabaseOpenHelper extends SQLiteOpenHelper {
// 
//     public final static String TABLE_NAME = "scientists";
//     public final static String SCIENTIST_NAME = "name";
//     final static String _ID = "_id";
//     public final static String[] columns = { _ID, SCIENTIST_NAME };
// 
//     final private static String CREATE_CMD =
// 
//             "CREATE TABLE scientists (" + _ID
//                     + " INTEGER PRIMARY KEY AUTOINCREMENT, "
//                     + SCIENTIST_NAME + " TEXT NOT NULL)";
// 
//     final private static String NAME = "scientists_db";
//     final private static Integer VERSION = 1;
//     final private Context mContext;
// 
//     public DatabaseOpenHelper(Context context) {
//         super(context, NAME, null, VERSION);
//         this.mContext = context;
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase db) {
//         db.execSQL(CREATE_CMD);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         // N/A
//     }
// 
//     public void deleteDatabase() {
//         mContext.deleteDatabase(NAME);
//     }
// }


// Path: DataManagement/app/src/main/java/qa/edu/qu/cse/cmps312/datamanagement/SQLDatabaseActivity.java
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import qa.edu.qu.cse.cmps312.datamanagement.SQLHelper.DatabaseOpenHelper;


                // execute database operations
                fix();

                // Redisplay data
                Cursor c = readScientists();
                mAdapter.changeCursor(c);
                mAdapter.notifyDataSetChanged();
            }
        });

    }

    // Insert several scientists records
    private void insertScientists() {

        ContentValues values = new ContentValues();

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Omar Al-Khayyam");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Al-Farabi");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Ibn Rushd");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Shakira");
        mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values);

        values.put(DatabaseOpenHelper.SCIENTIST_NAME, "Inb Khaldun");