package com.itti7.itimeu.data;

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

import com.itti7.itimeu.data.ItemContract.ItemEntry;
/**
 * Created by hyemin on 17. 7. 28.
 */

public class ItemDbHelper extends SQLiteOpenHelper {

    /** Name of the database file */
    private static final String DATABASE_NAME = "iTimeU.db";

    /**
     * Database version. If you change the database schema, you must increment the database version.
     */
    private static final int DATABASE_VERSION = 1;

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

    @Override
    public void onCreate(SQLiteDatabase db) {
        // CREATE TABLE list
        // (id INTEGER PRIMARY KEY, name TEXT, quantity TEXT, date Date, status INTEGER);
        // Create a String that contains the SQL statement to create the pets table
        String SQL_CREATE_LIST_TABLE = "CREATE TABLE " + ItemEntry.TABLE_NAME + "("
                + ItemEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                + ItemEntry.COLUMN_ITEM_NAME + " TEXT NOT NULL, "
                + ItemEntry.COLUMN_ITEM_QUANTITY + " TEXT, "
                + ItemEntry.COLUMN_ITEM_DATE + " TEXT, "
                + ItemEntry.COLUMN_ITEM_TOTAL_UNIT + " INTEGER NOT NULL DEFAULT 1, "
                + ItemEntry.COLUMN_ITEM_UNIT + " INTEGER NOT NULL DEFAULT 0, "
                + ItemEntry.COLUMN_ITEM_STATUS + " INTEGER NOT NULL DEFAULT 0);";

        db.execSQL(SQL_CREATE_LIST_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}

@@ -211,52 +211,104 @@
 ry;%0A
+%0A
 /**%0A * 
-Created by hyemin on 17. 7. 28
+Database helper for I Time U app. Manages database creation and version management
 .%0A */%0A
-%0A
 publ
@@ -353,24 +353,102 @@
 enHelper %7B%0A%0A
+    public static final String LOG_TAG = ItemDbHelper.class.getSimpleName();%0A%0A
     /** Name
@@ -711,295 +711,377 @@
     
-public ItemDbHelper(Context context) %7B%0A        super(context, DATABASE_NAME, null, DATABASE_VERSION);%0A    %7D%0A%0A    @Override%0A    public void onCreate(SQLiteDatabase db) %7B%0A        // CREATE TABLE list%0A        // (id INTEGER PRIMARY KEY, name TEXT, quantity TEXT, date Date, status INTEGER);
+/**%0A     * Constructs a new instance of %7B@link ItemDbHelper%7D.%0A     *%0A     * @param context of the app%0A     */%0A    public ItemDbHelper(Context context) %7B%0A        super(context, DATABASE_NAME, null, DATABASE_VERSION);%0A    %7D%0A%0A    /**%0A     * This is called when the database is created for the first time.%0A     */%0A    @Override%0A    public void onCreate(SQLiteDatabase db) %7B
 %0A   
@@ -1154,11 +1154,12 @@
 the 
-pet
+item
 s ta
@@ -1796,24 +1796,102 @@
 LE);%0A    %7D%0A%0A
+    /**%0A     * This is called when the database needs to be upgraded.%0A     */%0A
     @Overrid
@@ -1966,16 +1966,101 @@
 t i1) %7B%0A
+        // The database is still at version 1, so there's nothing to do be done here.
 %0A    %7D%0A%7D

주석 및 태그변수 추가