0
votes

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!

1

1 Answers

0
votes

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.