jeudi 23 avril 2015

SQLite CREATE TABLE syntax error (code 1)

I'm trying to create SQLite database like this :

private static final String UID = "_id";
private static final String NAME = "Name";
private static final String TYPE = "Type";
private static final String UNITS = "Units";
private static final String CURRENCY = "Currency";
private static final String PRICE = "Price";
private static final String ADD = "Default";
private static final String WEATHER = "Depends";
private static final String CREATE_TABLE = 
     " CREATE TABLE "+TABLE_NAME+
     " ( "  +UID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
     NAME+     " VARCHAR (255), "+
     TYPE+     " VARCHAR (255), "+
     UNITS+    " VARCHAR (255), "+
     CURRENCY+ " VARCHAR (255), "+
     PRICE+    " VARCHAR (255), "+
     ADD+      " VARCHAR (255), "+
     WEATHER+  " VARCHAR (255)  ); ";

public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE);
}

getting this error log:

Caused by: android.database.sqlite.SQLiteException: near "Default": 
syntax error (code 1): , while compiling: CREATE TABLE Meters ( _id INTEGER 
PRIMARY KEY AUTOINCREMENT, Name VARCHAR (255), Type VARCHAR (255), Units 
VARCHAR (255), Currency VARCHAR (255), Price VARCHAR (255), Default VARCHAR 
(255), Depends VARCHAR (255)  );

I really don't see a problem :-/ any advice what could be wrong are welcome, thanks guys

Aucun commentaire:

Enregistrer un commentaire