package com.maxiee.attitude.database.api;

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

import com.maxiee.attitude.database.DatabaseHelper;

import java.util.ArrayList;

/**
 * Created by maxiee on 15-6-11.
 */
public abstract class BaseDBApi {

    public static final String THOUGHT = "thought";
    public static final String TIMESTAMP = "timestamp";

    protected DatabaseHelper mDatabaseHelper;
    protected Context mContext;

    public BaseDBApi(Context context) {
        mDatabaseHelper = DatabaseHelper.instance(context);
        mContext = context;
    }

    protected void add(String table, ContentValues values) {
        SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
        db.beginTransaction();
        db.insert(table, null, values);
        db.setTransactionSuccessful();
        db.endTransaction();
    };
}

@@ -653,12 +653,12 @@
 ted 
-void
+long
  add
@@ -797,24 +797,35 @@
 n();%0A       
+ long key =
  db.insert(t
@@ -908,22 +908,43 @@
 ansaction();
+%0A%0A        return key;
 %0A    %7D;%0A%7D%0A

add method returns the id inserted.