Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Data Persistence Using SQLite for Structured Data Using sqlite3 to View Databases

André Gomes
André Gomes
3,537 Points

SQL creating Table error

Do you guys see any typo in this String? Because I had the same problem in the other table String and I solved by adding spaces between the strings combination.

private static final String CREATE_ANNOTATIONS = "CREATE TABLE " +
        ANNOTATIONS_TABLE + " (" + BaseColumns._ID +
        " INTEGER PRIMARY KEY AUTOINCREMENT," +
        COLUMN_ANNOTATION_X + " INTEGER, " +
        COLUMN_ANNOTATION_Y + " INTEGER, " +
        COLUMN_ANNOTATION_TITLE + " TEXT, " +
        COLUMN_ANNOTATION_COLOR + " TEXT, " +
        COLUMN_FOREIGN_KEY_MEME + " INTEGER, " +
        "FOREIGN KEY(" + COLUMN_FOREIGN_KEY_MEME +
        ") REFERENCES MEMES(_ID))"; 

My logcat:

 09-03 15:18:20.541    1924-1924/com.teamtreehouse.mememaker E/SQLiteLog﹕ (1) near       "ANNOTATIONS": syntax error
09-03 15:18:20.557    1924-1924/com.teamtreehouse.mememaker D/AndroidRuntime﹕ Shutting down VM
09-03 15:18:20.560    1924-1924/com.teamtreehouse.mememaker E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.teamtreehouse.mememaker, PID: 1924
    android.database.sqlite.SQLiteException: near "ANNOTATIONS": syntax error (code 1): , while compiling: ANNOTATIONS
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)