Search code examples
javasqliteandroid-studioandroid-sqlite

execSQL(); method not working properly. how can i make it work?


I am trying to create a new table but as soon as i run the app it shows me an error that something is not right in the db.execSQL();

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE "+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT");
}

Solution

  • Update your code :

    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE "+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT)”);
    

    }

    There is an issue in SQL query statement, I hope it helps you. Thanks