Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Last active September 15, 2018 00:22
Show Gist options
  • Save barmgeat/e3c00576bc633826acf8b093e99e4170 to your computer and use it in GitHub Desktop.
Save barmgeat/e3c00576bc633826acf8b093e99e4170 to your computer and use it in GitHub Desktop.
SQLite Helper Class
public class HelperClass extends SQLiteOpenHelper {
//Name of the database
private static final String DATABASE_NAME = "DBName.db";
//DB Version
private static final int DATABASE_VERSION = 1;
public HelperClass(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
/**
* onCreate when the database create for first time .
*/
@Override
public void onCreate(SQLiteDatabase db) {
// Statement to create the table
String CREATE_WORDS_TABLE = "CREATE TABLE " + WordsEntry.TABLE_NAME + " ("
+ WordsEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ WordsEntry.COLUMN_WORD + " TEXT NOT NULL, "
+ WordsEntry.COLUMN_WORD_T + " TEXT, "
+ WordsEntry.COLUMN_WORD_T2 + " TEXT, "
+ WordsEntry.COLUMN_WORD_T3 + " TEXT, "
+ WordsEntry.COLUMN_ARTIKEL + " INTEGER );";
// exceute the Statement
db.execSQL(CREATE_WORDS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int e) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment