0

private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "UnitConversion.db";

private static final String SQL_CREATE_ENTRIES =
        "CREATE TABLE " + DatabaseContract.FeedEntry.TABLE_NAME + " (" +
                DatabaseContract.FeedEntry._ID + " INTEGER PRIMARY KEY," +
                DatabaseContract.FeedEntry.COLUMN_NAME_UNIT_FROM + " TEXT," +
                DatabaseContract.FeedEntry.COLUMN_NAME_UNIT_CONVERTING_TO + " TEXT," +
                DatabaseContract.FeedEntry.COLUMN_NAME_Ratio + " TEXT)";

this is the error code:

android.database.sqlite.SQLiteException: near "between": syntax error (code 1): , while compiling: CREATE TABLE Conversions between units (_id INTEGER PRIMARY KEY,Converting from unit TEXT,Converting to unit TEXT,Ratio TEXT)

can't figure out what I've done wrong!

0

1 Answer 1

0

Your table name has spaces Conversions between units (or you should update DatabaseContract.FeedEntry.TABLE_NAME).

You probably wanted to name it something like conversions_between_units but if the table name really has spaces in it it should be between single or double quotes:

"CREATE TABLE \"" + DatabaseContract.FeedEntry.TABLE_NAME + "\" ("

even though single quotes are supported by SQLite, but the portable way is to use double quotes.

The same goes for COLUMN_NAME_UNIT_FROM and COLUMN_NAME_UNIT_CONVERTING_TO which also contain spaces.

Sign up to request clarification or add additional context in comments.

1 Comment

Comments are not for extended discussion; this conversation has been moved to chat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.