I'm having issues after releasing a new version of my android app in android studio.
Here is the problem: I have a quiz app with an SQlite database in which questions and answers have been populated with SQLite database browser. Now when I add new questions to the database tables and create a new database version, database dont seem to reflect in the updated app. The tutorials I find online on database upgrades enphasizes only on database that is created as application starts. like this
Question: How do I handle database upgrade only when I add new records to an already existing table in SQLite?
What I have tried:
(1) in DatabaseOpenHelper OnUpgrade()
method, I dropped the tables in which new records were added.
result : App crashed activity starts
(2) Leave the OnUpdrade()
method empty.
result : The newly added records did not reflect
Extra data: DatabaseOpenHelper OnCreate() method is also empty
Code
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table if exists "+ DatabaseDescription.LectureNotes.TABLE_NAME);
db.execSQL("drop table if exists "+ DatabaseDescription.QuestionAnswer.TABLE_NAME);
db.execSQL("drop table if exists "+ DatabaseDescription.Test.TABLE_NAME);
db.execSQL("drop table if exists "+ DatabaseDescription.Subjects.TABLE_NAME);
db.execSQL("drop table if exists "+ DatabaseDescription.Topics.TABLE_NAME);
db.execSQL("drop table if exists "+ DatabaseDescription.Year.TABLE_NAME);
}