[Solved] Android::SQLite Error: no such table


Your onCreate() has SQL syntax errors:

String DATABASE_CREATE_FIRST ="CREATE TABLE IF NOT EXISTS"+ NAME_TABLE
                      +"(" + KEY_NAME +TEXT_TYPE+ COMMA_SEP +
                      KEY_HR+TEXT_TYPE+ COMMA_SEP  + 
                      KEY_IBI +TEXT_TYPE+ COMMA_SEP+
                      KEY_HMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_HMAX+TEXT_TYPE+ COMMA_SEP+
                      KEY_IMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_IMAX+TEXT_TYPE+ COMMA_SEP+
                      KEY_BMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_BMAX+TEXT_TYPE+ COMMA_SEP+
                     ")";
  • No space between EXISTS and table name.

  • Extra comma after last column specification.

So:

String DATABASE_CREATE_FIRST ="CREATE TABLE IF NOT EXISTS "+ NAME_TABLE
                      +"(" + KEY_NAME +TEXT_TYPE+ COMMA_SEP +
                      KEY_HR+TEXT_TYPE+ COMMA_SEP  + 
                      KEY_IBI +TEXT_TYPE+ COMMA_SEP+
                      KEY_HMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_HMAX+TEXT_TYPE+ COMMA_SEP+
                      KEY_IMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_IMAX+TEXT_TYPE+ COMMA_SEP+
                      KEY_BMIN+TEXT_TYPE+ COMMA_SEP+
                      KEY_BMAX+TEXT_TYPE+
                     ")";

Clean up your app data when changing the db schema to force onCreate() to be called again.


Edited to add after comments: Your onUpgrade() is also broken. It fails to do any modifications to an existing database and will cause infinite recursion (causing StackoverflowError). Easy but data-losing solution is to DROP TABLE tablename and then call onCreate().

4

solved Android::SQLite Error: no such table