Back to project page LearnByHeart.
The source code is released under:
Apache License
If you think the Android project LearnByHeart 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.mps.learn.pb.db; // w ww . j a v a2 s . c o m import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; import com.mps.learn.pb.db.PhraseReaderContract.PhraseEntry; public class DatabaseHelper extends SQLiteOpenHelper { private static final String TAG = DatabaseHelper.class.getSimpleName(); public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME = "FeedReader.db"; private static final String TIMESTAMP = " TIMESTAMP"; private static final String TEXT_TYPE = " TEXT"; private static final String INTEGER_TYPE = " INTEGER"; private static final String COMMA_SEP = ","; private static final String SQL_CREATE_PHRASE_ENTRIES = "CREATE TABLE " + PhraseEntry.TABLE_NAME + " (" + PhraseEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + PhraseEntry.COLUMN_NAME_TITLE + TEXT_TYPE + COMMA_SEP + PhraseEntry.COLUMN_NAME_USAGE_EN + TEXT_TYPE + COMMA_SEP + PhraseEntry.COLUMN_NAME_USAGE_PB + TEXT_TYPE + COMMA_SEP + PhraseEntry.COLUMN_NAME_RES_URL + TEXT_TYPE + COMMA_SEP + PhraseEntry.COLUMN_NAME_UPDATED + TIMESTAMP + " )"; private static final String SQL_DELETE_PHRASE_ENTRIES = "DROP TABLE IF EXISTS " + PhraseEntry.TABLE_NAME; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { Log.i(TAG, SQL_CREATE_PHRASE_ENTRIES); db.execSQL(SQL_CREATE_PHRASE_ENTRIES); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(SQL_DELETE_PHRASE_ENTRIES); onCreate(db); } public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { onUpgrade(db, oldVersion, newVersion); } }