package com.serviq.serviq;

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

/**
 * Created by gildardo on 8/12/16.
 */

public class ServiqDBOpenHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "serviq.db";
    private static final int DATABASE_VERSION = 1;

    public static final String TABLE_COMIDA = "comida";
    public static final String COLUMN_ID = "cId";
    public static final String COLUMN_TITLE = "comida";
    public static final String COLUMN_DESC = "descripcion";
    public static final String COLUMN_PRICE = "precio";
    public static final String COLUMN_TIME = "tiempo";
    public static final String COLUMN_IMAGE = "imagen";

    private static final String TABLE_CREATE =
            "CREATE TABLE " + TABLE_COMIDA +  " (" +
            COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
            COLUMN_TITLE + " TEXT, " + COLUMN_DESC + " TEXT," +
            COLUMN_PRICE + " NUMERIC, " + COLUMN_TIME + " NUMERIC, " +
            COLUMN_IMAGE + " TEXT " + ")";

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

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(TABLE_CREATE);
        Log.i("ServiQ", "Table has been created ;D");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_COMIDA);
        onCreate(sqLiteDatabase);
    }
}

@@ -778,24 +778,700 @@
  %22imagen%22;%0A%0A
+    public static final String TABLE_CARRITO_ITEM = %22carrito_item%22;%0A    public static final String ITEM_COLUMN_ID = %22id%22;%0A    public static final String ITEM_COLUMN_DESC = %22descripcion%22;%0A    public static final String ITEM_COLUMN_CANT = %22cantidad%22;%0A    public static final String ITEM_COMIDA_ID = %22comida_id%22;%0A%0A    private static final String TABLE_CARRITO_CREATE = %22CREATE TABLE %22%0A            + TABLE_CARRITO_ITEM + %22(%22 + ITEM_COLUMN_ID + %22 INTEGER PRIMARY KEY, %22%0A            + ITEM_COLUMN_DESC + %22 TEXT, %22 + ITEM_COLUMN_CANT + %22 NUMERIC, %22%0A            + ITEM_COMIDA_ID + %22 INT, %22 + %22FOREIGN KEY(%22 + ITEM_COMIDA_ID + %22) REFERENCES %22%0A            + COLUMN_ID + %22(id) %22 + %22)%22;%0A%0A
     private 
@@ -1505,16 +1505,16 @@
 REATE =%0A
-
         
@@ -2039,16 +2039,70 @@
 REATE);%0A
+        sqLiteDatabase.execSQL(TABLE_CARRITO_CREATE);%0A
         
@@ -2238,24 +2238,24 @@
 , int i1) %7B%0A
-
         sqLi
@@ -2314,16 +2314,94 @@
 OMIDA);%0A
+        sqLiteDatabase.execSQL(%22DROP TABLE IF EXISTS %22 + TABLE_CARRITO_ITEM);%0A
         

Add table Carrito_Item