Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created Mar 20, 2017
Embed
What would you like to do?
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