Back to project page groceryviewer.
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.
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); } }