-
-
Save jezinka/67ead062e9ca1ab84e7814ca360d6d07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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