0

I have implemented multiple SQLiteOpenHelper class for the same database same version. (my1SQLiteOpenHelper class, my2SQLiteOpenHelper class, my3SQLiteOpenHelper class)

I have put create tables sql statement in oncreate and onupgrade methods for all classes

When i run... only my1SQLiteOpenHelper class oncreate method is called. any other classes oncreate or onupgrade is Not getting called.

so i'm getting table missing error.

1) Any idea why this is happening..?

2) Is it possible to use upgrade a existing database from another instance of my2SQLiteOpenHelper ?

3) Can you force run onUpgrade method ?

Dinushka
  • 118
  • 2
  • 11
  • `SQLiteOpenHelper` manages database files by name and version number. The first one brings your database file to the given version. The rest have nothing left to do. https://stackoverflow.com/questions/21881992/when-is-sqliteopenhelper-oncreate-onupgrade-run – laalto Feb 26 '19 at 05:59
  • i tried adding "getWritableDatabase()" but it does make any difference also tried changing versions. i'm trying to add new tables to existing database, using another new `SQLiteOpenHelper` implementation. then which method is called `Oncreate()` or `onupgrade()`? In my case non of them are getting called, and a error comes saying table missing. – Dinushka Feb 26 '19 at 06:20
  • Use only one `SQLiteOpenHelper` per database. – laalto Feb 26 '19 at 06:45
  • ok,thanks can you unmark duplicate – Dinushka Feb 26 '19 at 07:12

0 Answers0