My onCreate method of the SQLiteOpenHelper contains the following code:
Log.d("mytag", "oncreate is called");
db.execSQL("CREATE TABLE TrainingSession (id INTEGER PRIMARY KEY, session_date TEXT, session_status TEXT)");
Log.d("mytag", "tables were created");
The Logcat output contains only the first Log.d:
oncreate is called
And then the app crashes. What is wrong with my create table statement?
EDIT:
Logcat actually says that the table TrainingSession already exists. However, my onUpgrade method looks like this:
Log.d("mytag", "onupgrade is called");
db.execSQL("DROP TABLE IF EXISTS TrainingSet; DROP TABLE IF EXISTS TrainingSession;");
onCreate(db);
and the Logcat output of that method is as expected, the method does get called:
onupgrade is called
If onUpgrade is called and the tables are deleted, then why does onCreate say that TrainingSession already exists?