-1

I have the following:

public static final String COL_4 = "ID";

And:

public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table " + TABLE_NAME + " (LastScore INTEGER, Highscore INTEGER, Title TEXT, ID BOOLEAN)");

This works perfectly;

However, if I change ID to, say, "John" (in the declaration and the execSQL),I get the following error:

android.database.sqlite.SQLiteException: no such column: John (code 1): , while compiling: UPDATE Player_Stats SET LastScore=?,Title=?,John=?,Highscore=? 

Any idea how such a change in the name of the String throw an exception? Thank you!

EDIT: The problem is not with Boolean. The same problem happens if I change it to Integer. Works with "ID", doesn't with "John"

Ziad
  • 63
  • 1
  • 9
  • do you want to change column name ID to John ? – Sandeep dhiman May 29 '17 at 05:11
  • `John` - it's not a column, just a value in it. Please, provide your bind statement – FieryCat May 29 '17 at 05:11
  • in your COL_4 ="ID" data type is boolean – Ratilal Chopda May 29 '17 at 05:12
  • Yes, I want to call my variable COL_4 but I want its value to be "John" rather than "ID". When I do: public static final String COL_4 = "ID" everything works. When I do: public static final String COL_4 = "John" I get the exception mentioned above – Ziad May 29 '17 at 05:13
  • @RatilalChopda: Yes, it is. I have the same problem if I make it Integer; works with ID, doesn't with "John". I just want to change the column name from ID to John, which will hold boolean values – Ziad May 29 '17 at 05:15
  • @Ziad you mention that ID as column name while creating table ,but while update you mention that column name is JHON. how it will work dude. – Palanivelraghul May 29 '17 at 05:20
  • @Palanivelraghul: No, in fact when I change the column name to John, I change it in the execSQL, too – Ziad May 29 '17 at 05:23

2 Answers2

0

Boolean Data type

There is no native boolean data type for SQLite. SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
0

It seems when I first ran it, the Database was created with the ID column. Hence, I am only calling the onUpgrade() later rather than the onCreate(), which is expecting a column called ID rather than John. I am in the incapability to do this, but I believe deleting the database and starting over will solve the issue. Thanks for the support!

Ziad
  • 63
  • 1
  • 9