2

I am trying to create tables in my DBhelper class and I'm continually getting this error: "No table created PAYEES".

Because of this, the rest of the DB operations are also not working. I have put sufficient time on proof reading my CreateTableQuries. Here is one of my queries that fail:

private static final  String tbl3_create_string = "CREATE TABLE "+tbl3_name+" ( "+col1_tbl3_name+" INTEGER PRIMARY KEY AUTOINCREMENT, " +
            col2_tbl3_name+" TEXT, "+col3_tbl1_name+" TEXT )";

public void onCreate(SQLiteDatabase db) {

    try {
        db.execSQL(tbl1_create_string);
        db.execSQL(tbl2_create_string);
        db.execSQL(tbl3_create_string);
        db.execSQL(tbl4_create_string);
        db.execSQL(tbl5_create_string);
        global=1;
    }
    catch (SQLException e)
    {
        Log.e("DB: OnCreate Method ", e.getMessage());
        global=0;
    }
}

When I check this on SQLite's query validator it is working.

mattfred
  • 2,689
  • 1
  • 22
  • 38
user3319128
  • 25
  • 1
  • 7

1 Answers1

0

onCreate in the dbHelper class is only called the first time the application is installed. If you have made updates to this class, either uninstall the app and reinstall it, or the more correct way, change the version number and the onUpdate method will be called. Also add some logging to make sure it is running.

mattfred
  • 2,689
  • 1
  • 22
  • 38
  • 1
    You dont have to reinstall the app for that..You can just call the onUpgrade method with a new version and in the onUpgrade method add code to drop the old table. – Psypher Jul 04 '15 at 04:33
  • That is correct. I have updated my answer. – mattfred Jul 04 '15 at 17:27