I read all other "SQLiteException no such table" messages but didn't find an answer to my point.
I'm creating an android application with multiple tables in database. I build it step by step. I created first table A, and a form to add/edit data. I inspired myself with LoaderThrottle android sample. It was working perfectly. After this, I created table B, exactly like table A, and a form to add data.
I then saw I forgot a field in table B. I tried to add this field and switched table B to version 2. But I had a lot of problem. "downgrade" and "upgrade" errors... So I erased application data and un-installed the application from device, so database is deleted and recreated on first launch.
But now, when I launch the application, I have the exception << android.database.sqlite.SQLiteException: no such table: A: , while compiling: SELECT name, _id FROM A WHERE ((active = 1 ))>> ?!?
Why is dbHelper not creating the database? Do I have to explicitly call its onCreate method? Do I need unique dbHelper for all tables of database or one dbHelper for each table (what I have now)?
Further information : - In manifest, I have two providers, linked to content provider of each table.
Edit : Here is creation code for each table.
Table A (for which I have the exception) :
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + ActivityTable.TABLE_NAME + " ("
+ ActivityTable._ID + " INTEGER PRIMARY KEY, "
+ ActivityTable.COLUMN_NAME_TITLE + " TEXT NOT NULL, "
+ ActivityTable.COLUMN_NAME_CODE + " TEXT, "
+ ActivityTable.COLUMN_NAME_ACTIVE + " smallint NOT NULL DEFAULT 1, "
+ ActivityTable.COLUMN_NAME_CPTI + " smallint NOT NULL DEFAULT 1 "
+ ");");
}
Table B :
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TrackTable.TABLE_NAME + " ("
+ TrackTable._ID + " INTEGER PRIMARY KEY, "
+ TrackTable.COLUMN_NAME_DATE + " long NOT NULL, "
+ TrackTable.COLUMN_NAME_ACTIVITY_ID + " int NOT NULL DEFAULT 0, "
+ TrackTable.COLUMN_NAME_DAYPART + " smallint NOT NULL DEFAULT 0, "
+ TrackTable.COLUMN_NAME_NPQ + " smallint NOT NULL DEFAULT 0, "
+ TrackTable.COLUMN_NAME_NBPID + " long NOT NULL DEFAULT 0 "
+ ");");
}
Thanks in advance for any clue. Florent