mercredi 31 décembre 2014

syntax error (code 1): , while compiling: CREATE TABLE

What am I missing in my sql command?



public class PhoneDal extends SQLiteOpenHelper {

// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = Constants.DB_NAME;

public static final String BLOCKED_PHONES_TABLE = "BLOCKED_PHONES_TABLE";

public PhoneDal(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_BLOCKED_PHONES_TABLE =
"CREATE TABLE "+ BLOCKED_PHONES_TABLE +
" ( "+ KEY_ID+" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL DEFAULT 1, "
+ KEY_PHONE+" TEXT, "
+ KEY_IS_BLOCKED+" BIT," +
" UNIQUE "+ KEY_PHONE+" )";

db.execSQL(CREATE_BLOCKED_PHONES_TABLE);
}


and the error is



android.database.sqlite.SQLiteException: near "KEY_PHONE": syntax error (code 1): , while compiling: CREATE TABLE BLOCKED_PHONES_TABLE ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL DEFAULT 1, KEY_PHONE TEXT, KEY_IS_BLOCKED BIT, UNIQUE KEY_PHONE )
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)

Aucun commentaire:

Enregistrer un commentaire