package com.example.georgekaraolanis.project9_habittracker;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.example.georgekaraolanis.project9_habittracker.data.HabitContract;
import com.example.georgekaraolanis.project9_habittracker.data.HabitDbHelper;

public class MainActivity extends AppCompatActivity {

    /*Tag for logging*/
    private static final String LOG_TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    /*Insert a habit into the database*/
    private void insertHabit(String name,String time, int category){

        /*Create helper*/
        HabitDbHelper helper = new HabitDbHelper(this);

        /*Get database in write mode*/
        SQLiteDatabase db = helper.getWritableDatabase();

        /*Get ContentValues item*/
        ContentValues values = new ContentValues();

        /*Put in values*/
        values.put(HabitContract.HabitEntry.COLUMN_HABIT_NAME,name);
        values.put(HabitContract.HabitEntry.COLUMN_HABIT_TIME,time);
        values.put(HabitContract.HabitEntry.COLUMN_HABIT_CATEGORY,category);

        /*Insert into database*/
        long newRowId = db.insert(HabitContract.HabitEntry.TABLE_NAME,null,values);

        /*Check result*/
        if (newRowId == -1 ){
            Log.d(LOG_TAG,"Error inserting value into database");
        }
        else{
            Log.d(LOG_TAG,"Value inserted successfully");
        }

    }

}

@@ -92,16 +92,48 @@
 Values;%0A
+import android.database.Cursor;%0A
 import a
@@ -171,16 +171,16 @@
 tabase;%0A
-
 import a
@@ -821,21 +821,20 @@
 d insert
-Habit
+Data
 (String 
@@ -1695,24 +1695,24 @@
 essfully%22);%0A
-
         %7D%0A%0A 
@@ -1717,10 +1717,903 @@
 %0A    %7D%0A%0A
+    /*Read an entry or entries from database*/%0A    private Cursor readData()%7B%0A%0A        /*Create helper*/%0A        HabitDbHelper helper = new HabitDbHelper(this);%0A%0A        /*Create and/or read from database*/%0A        SQLiteDatabase db = helper.getReadableDatabase();%0A%0A        /*Define projection. Let's say we want all columns*/%0A        String%5B%5D projection = %7B%0A                HabitContract.HabitEntry._ID,%0A                HabitContract.HabitEntry.COLUMN_HABIT_NAME,%0A                HabitContract.HabitEntry.COLUMN_HABIT_TIME,%0A                HabitContract.HabitEntry.COLUMN_HABIT_CATEGORY%0A        %7D;%0A%0A        /*Perform query*/%0A        Cursor cursor = db.query(%0A                HabitContract.HabitEntry.TABLE_NAME,%0A                projection,%0A                null,%0A                null,%0A                null,%0A                null,%0A                null%0A        );%0A%0A        return cursor;%0A%0A    %7D%0A%0A
 %7D%0A

Add method to query database for data