Skip to content

Instantly share code, notes, and snippets.

@thanhnh98
Created February 2, 2020 12:45
Show Gist options
  • Save thanhnh98/fc673ec320fefc9463afc933e3c99f78 to your computer and use it in GitHub Desktop.
Save thanhnh98/fc673ec320fefc9463afc933e3c99f78 to your computer and use it in GitHub Desktop.
public class FeedReaderDbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version.
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "FeedReader.db";
public FeedReaderDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL(SQL_CREATE_ENTRIES);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// This database is only a cache for online data, so its upgrade policy is
// to simply to discard the data and start over
db.execSQL(SQL_DELETE_ENTRIES);
onCreate(db);
}
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onUpgrade(db, oldVersion, newVersion);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment