Listing 14.6 Shows Error even in copied code from Solutions File


Having gotten to the end of page 296 (Implicit Intents) the app crashed with LogCat reporting it couldn’t find ‘suspect’ in the database. I tried to diagnose the cause but failed and so I reverted to a backup (End of Chapter 13). However upon reaching the end of 14.6 (Creating crime table) Android Studio flagged the comma in this line:

CrimeTable.Cols.DATE + ", " +

with this error:

')',<column constraint>, <type name> or comma expected, got ';'

I checked to whole onCreate function I could see no difference to that in the book. I typed over the comma with a comma and the error jumped to the previous line but flagging the end quotation mark (same error). I then commented the whole thing and retyped it out but the same error popped up so I copied the onCreate function from the Solutions File and that too had the same error.

If I ‘Run the App’ on my device it crashes on load (obviously) and LogCat reports this:

Caused by: android.database.sqlite.SQLiteException: near ";": syntax error (code 1): , while compiling: create table crimes( _id integer primary key autoincrement, uuid, title, date;, solved)

In between all this I had closed Android Studio, restarted laptop and relaunched Android Studio (thinking it might be a glitch as it did not flag this when I managed to get to page 296) but it still reports the same error. As far as I can see no-one else has had this issue which is why it is baffling me.

Any ideas?

Here is my code for



import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class CrimeBaseHelper extends SQLiteOpenHelper {
private static final int VERSION = 1;
private static final String DATABASE_NAME = “crimeBase.db”;

public CrimeBaseHelper(Context context) {
    super(context, DATABASE_NAME, null, VERSION);

public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table " + CrimeTable.NAME + "(" +
            " _id integer primary key autoincrement, " +
            CrimeTable.Cols.UUID + ", " +
            CrimeTable.Cols.TITLE + ", " +
            CrimeTable.Cols.DATE + ", " +
            CrimeTable.Cols.SOLVED +

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {





Ha, found it! In my defining of table columns in I accidently added a ‘;’ within the string quotations for DATE.

I put:

public static final String DATA = "date;";

What a stupid mistake.