Android SQLite issue – table … has no column named

It seems that you added some columns later in the database. I do agree with Ken Wolf and you should consider uninstalling and re-installing your app. One better approach is, drop and recreate all tables in onUpdate method, and increase the db version every time you change the schema.

Well, If you are confindent about syntax for creating table, than it may happen
when you add new column in your same table, for that…

1) Unistall from your device and run it again.

OR

2) Setting -> app -> ClearData

OR

3) Change DATABASE_NAME in your “DatabaseHandler” class
( I faced same problem. But I suuceed by changing DATABASE_NAME.)

OR

4) Change DATABASE_VERSION in your “DatabaseHandler” class
(If you have added new column than it will upgrade autimatically)

public DatabaseHandler(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

The SQL code looks fine.
I think that you forgot to call open() on your database object that you created.

add this methods to you SQL class:

private DbHelper ourHelper;
private final Context ourContext;
private SQLiteDatabase ourDatabase;

public DataBaseMain open() throws SQLException{ 
    // Open the database to make her writeable, must be called before writing 
    // to database

    ourHelper = new DbHelper(ourContext);
    ourDatabase = ourHelper.getWritableDatabase();
    return this;
}

public void close(){                
    // Closing the database for writing, avoids error.
    ourHelper.close();
}

And use when you want to call you DB.

Leave a Comment