Android Open Source - groceryviewer Grocery List Helper






From Project

Back to project page groceryviewer.

License

The source code is released under:

GNU General Public License

If you think the Android project groceryviewer 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.github.knrajago.groceryviewer.localdb;
/*from   www . j  ava  2 s .  co  m*/
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.provider.BaseColumns;

import static com.github.knrajago.groceryviewer.constants.GroceryViewerConstants.ITEM_COL;
import static com.github.knrajago.groceryviewer.constants.GroceryViewerConstants.TABLE_NAME;

public class GroceryListHelper extends SQLiteOpenHelper {

  private static final String TEXT_TYPE = " TEXT";
  //private static final String INT_TYPE = " INTEGER";
  private static final String COMMA_SEP = ",";
  public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "grewords.db";
  private static final String SQL_CREATE_ENTRIES =
      "CREATE TABLE " + TABLE_NAME + " (" +
          BaseColumns._ID + " INTEGER PRIMARY KEY," +
          ITEM_COL + TEXT_TYPE + COMMA_SEP +
          //WORD_COL + TEXT_TYPE + COMMA_SEP +
          //EXAMPLE_COL + TEXT_TYPE + COMMA_SEP + 
          //STATE_COL + TEXT_TYPE + COMMA_SEP +
          //TXING_COL + TEXT_TYPE + COMMA_SEP +
          " UNIQUE(" + ITEM_COL + "))";
  
  public static final String SQL_DELETE_ENTRIES =
        "DROP TABLE IF EXISTS " + TABLE_NAME;
  
  public GroceryListHelper(Context pContext) {
    super(pContext, DATABASE_NAME, null, DATABASE_VERSION);
  }
  
  public GroceryListHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) 
  {
    super(context, name, factory, version, errorHandler);
  }
  
  public GroceryListHelper(Context context, String name,
      CursorFactory factory, int version) {
    super(context, name, factory, version);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL(SQL_CREATE_ENTRIES);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL(SQL_DELETE_ENTRIES);
    db.execSQL(SQL_CREATE_ENTRIES);
  }
  
  @Override
  public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL(SQL_DELETE_ENTRIES);
    db.execSQL(SQL_CREATE_ENTRIES);
  }

}




Java Source Code List

android.UnusedStub.java
com.github.knrajago.groceryviewer.GroceryViewerActivity.java
com.github.knrajago.groceryviewer.constants.GroceryViewerConstants.java
com.github.knrajago.groceryviewer.listadapters.GroceryListAdapter.java
com.github.knrajago.groceryviewer.localdb.GroceryListHelper.java
com.github.knrajago.groceryviewer.observers.GroceryViewerObserver.java
com.github.knrajago.groceryviewer.providers.GroceryViewerContentProvider.java
com.github.knrajago.groceryviewer.services.GroceryViewerSyncService.java
com.github.knrajago.groceryviewer.syncadapters.GoogleSpreadsheetRefresher.java
com.github.knrajago.groceryviewer.threadedutils.GoogleAuthTokenRetriever.java
com.github.knrajago.groceryviewer.utils.GroceryViewerUtils.java