Android Open Source - camp-food-manager Camp Food Manager Data Base






From Project

Back to project page camp-food-manager.

License

The source code is released under:

GNU General Public License

If you think the Android project camp-food-manager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.V4Creations.FSMK.campfoodmanager.db;
//from  ww  w  .  ja v  a  2 s.  co  m
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class CampFoodManagerDataBase {

  String TAG = "CampFoodManagerDataBase";
  public static final String DATABASE_NAME = "camp_food_manager_db";
  public static final int DATABASE_VERSION = 1;
  public static final String TABLE_NAME = "food_history";
  public static final String COL_ID = "id";
  public static final String COL_TYPE = "food_session_type";
  public static final String COL_DATE = "food_date";
  public static final String COL_COUNT = "count(*)";

  public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS "
      + TABLE_NAME + "(" + COL_ID + " INTEGER, " + COL_TYPE
      + " INTEGER, " + COL_DATE + " VARCHAR(50), " + "PRIMARY KEY ("
      + COL_ID + "," + COL_TYPE + "," + COL_DATE + "));";
  public static final String DROP_TABLE = "DROP TABLE IF EXISTS "
      + TABLE_NAME;
  private final Context mContext;
  private DatabaseHelper mDatabaseHelper;

  public CampFoodManagerDataBase(Context context) {
    mContext = context;
    mDatabaseHelper = new DatabaseHelper(mContext);
  }

  public void close() {
    mDatabaseHelper.close();
  }

  public boolean insertFoodDetails(int id, int type, String dateString) {
    ContentValues contentValues = new ContentValues();
    contentValues.put(COL_ID, id);
    contentValues.put(COL_TYPE, type);
    contentValues.put(COL_DATE, dateString);
    SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
    if (db.insert(TABLE_NAME, COL_ID, contentValues) != -1)
      return true;
    return false;
  }

  public boolean deleteFoodDetails(int id, int type, String dateString) {
    SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
    if (db.delete(TABLE_NAME, COL_ID + "=? AND " + COL_TYPE + "=? AND "
        + COL_DATE + "=?",
        new String[] { Integer.toString(id), Integer.toString(type),
            dateString }) != 0)
      return true;
    return false;
  }

  public int getCount(String dateString, int type) {
    SQLiteDatabase db = mDatabaseHelper.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, new String[] { COL_COUNT },
        COL_DATE + "=? AND " + COL_TYPE + "=?", new String[] {
            dateString, Integer.toString(type) }, null, null, null);
    String result = "0";
    if (cursor.moveToNext()) {
      result = cursor.getString(cursor.getColumnIndex(COL_COUNT));
    }
    cursor.close();
    return Integer.parseInt(result);
  }

  public boolean getQueryResult(String idString, String typeString,
      String dateString) {
    SQLiteDatabase db = mDatabaseHelper.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, new String[] { COL_ID, COL_DATE,
        COL_TYPE }, COL_ID + "=? AND " + COL_DATE + "=? AND "
        + COL_TYPE + "=?", new String[] { idString, dateString,
        typeString }, null, null, null);
    boolean result = cursor.moveToNext();
    cursor.close();
    return result;
  }

  public void clearAllData() {
    SQLiteDatabase db = mDatabaseHelper.getReadableDatabase();
    db.execSQL(CampFoodManagerDataBase.DROP_TABLE);
    db.execSQL(CampFoodManagerDataBase.CREATE_TABLE);
  }

}




Java Source Code List

com.V4Creations.FSMK.campfoodmanager.adapter.ResultListViewAdapter.java
com.V4Creations.FSMK.campfoodmanager.db.CampFoodManagerDataBase.java
com.V4Creations.FSMK.campfoodmanager.db.DatabaseHelper.java
com.V4Creations.FSMK.campfoodmanager.db.GetAllStudensDetailsHelperAsynzTask.java
com.V4Creations.FSMK.campfoodmanager.db.GetDetailsHelperAsynzTask.java
com.V4Creations.FSMK.campfoodmanager.flash.Constants.java
com.V4Creations.FSMK.campfoodmanager.flash.Droid22Flashlight.java
com.V4Creations.FSMK.campfoodmanager.flash.Flashlight.java
com.V4Creations.FSMK.campfoodmanager.flash.FroyoLedFlashlight.java
com.V4Creations.FSMK.campfoodmanager.flash.HtcLedFlashlight.java
com.V4Creations.FSMK.campfoodmanager.flash.LedFlashlightReceiver.java
com.V4Creations.FSMK.campfoodmanager.flash.Moto21LedFlashlight.java
com.V4Creations.FSMK.campfoodmanager.fragment.MenuFragment.java
com.V4Creations.FSMK.campfoodmanager.interfaces.GetFullStudentsDetailsInterface.java
com.V4Creations.FSMK.campfoodmanager.interfaces.GetSingleItemDetailsInterface.java
com.V4Creations.FSMK.campfoodmanager.ui.CampFoodManagerMainActivity.java
com.V4Creations.FSMK.campfoodmanager.ui.PreferencesActivity.java
com.V4Creations.FSMK.campfoodmanager.util.BaseActivity.java
com.V4Creations.FSMK.campfoodmanager.util.Settings.java
com.google.zxing.client.android.AmbientLightManager.java
com.google.zxing.client.android.BeepManager.java
com.google.zxing.client.android.CaptureActivityHandler.java
com.google.zxing.client.android.DecodeFormatManager.java
com.google.zxing.client.android.DecodeHandler.java
com.google.zxing.client.android.DecodeHintManager.java
com.google.zxing.client.android.DecodeThread.java
com.google.zxing.client.android.FinishListener.java
com.google.zxing.client.android.InactivityTimer.java
com.google.zxing.client.android.IntentSource.java
com.google.zxing.client.android.Intents.java
com.google.zxing.client.android.ViewfinderResultPointCallback.java
com.google.zxing.client.android.ViewfinderView.java
com.google.zxing.client.android.camera.AutoFocusManager.java
com.google.zxing.client.android.camera.CameraConfigurationManager.java
com.google.zxing.client.android.camera.CameraManager.java
com.google.zxing.client.android.camera.FrontLightMode.java
com.google.zxing.client.android.camera.PreviewCallback.java
com.google.zxing.client.android.camera.exposure.DefaultExposureInterface.java
com.google.zxing.client.android.camera.exposure.ExposureInterface.java
com.google.zxing.client.android.camera.exposure.ExposureManager.java
com.google.zxing.client.android.camera.exposure.FroyoExposureInterface.java
com.google.zxing.client.android.camera.open.DefaultOpenCameraInterface.java
com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface.java
com.google.zxing.client.android.camera.open.OpenCameraInterface.java
com.google.zxing.client.android.camera.open.OpenCameraManager.java
com.google.zxing.client.android.common.PlatformSupportManager.java
com.google.zxing.client.android.common.executor.AsyncTaskExecInterface.java
com.google.zxing.client.android.common.executor.AsyncTaskExecManager.java
com.google.zxing.client.android.common.executor.DefaultAsyncTaskExecInterface.java
com.google.zxing.client.android.common.executor.HoneycombAsyncTaskExecInterface.java