Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created March 20, 2017 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/67ead062e9ca1ab84e7814ca360d6d07 to your computer and use it in GitHub Desktop.
Save jezinka/67ead062e9ca1ab84e7814ca360d6d07 to your computer and use it in GitHub Desktop.
public class CoNaObiadDbHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 5;
public static final String DATABASE_NAME = "CoNaObiad.db";
public CoNaObiadDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
BaseTable table = new MealContract();
db.execSQL(table.getCreateEntriesQuery());
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
BaseTable table = new MealContract();
db.execSQL(table.getDropTableQuery());
onCreate(db);
}
public void cleanData() {
SQLiteDatabase db = this.getWritableDatabase();
BaseTable table = new MealContract();
db.execSQL(table.getDeleteEntriesQuery());
}
public void insertValuesDbHelper(String tableName, ContentValues contentValues) {
SQLiteDatabase db = this.getWritableDatabase();
db.insert(tableName, null, contentValues);
db.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment