title: Error on sqlite database creation - Android
body: <p>I am trying to add a new column to my sqlite database. I have previously added an extra column (email) and have had no problem at all. Below is my DbHelper class for creation.</p>
  
  <pre><code>public class DbHelper extends SQLiteOpenHelper {
  public static String DATABASE_NAME="userdata";
  public static final String TABLE_NAME="user";
  public static final String KEY_FNAME="fname";
  public static final String KEY_LNAME="lname";
  public static final String KEY_EMAIL="email";
  public static final String KEY_CHECK="check";
  public static final String KEY_ID="id";
  public DbHelper(Context context) {
      super(context, DATABASE_NAME, null, 1);
  
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      String CREATE_TABLE="CREATE TABLE " +TABLE_NAME+" ("+KEY_ID+" INTEGER PRIMARY KEY, "+KEY_FNAME+" TEXT, "+KEY_LNAME+" TEXT, "+KEY_CHECK+" TEXT)";
      db.execSQL(CREATE_TABLE);
  
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
      onCreate(db);
  
  }
  
  }
  </code></pre>
  
  <p>When the db is created it is displayed from my mainactivity:</p>
  
  <pre><code>private void displayData() {
      dataBase = mHelper.getWritableDatabase();
      Cursor mCursor = dataBase.rawQuery("SELECT * FROM "
              + DbHelper.TABLE_NAME, null);
  
      userId.clear();
      user_fName.clear();
      user_lName.clear();
      user_eMail.clear();
      user_cHeck.clear();
      if (mCursor.moveToFirst()) {
          do {
              userId.add(mCursor.getString(mCursor.getColumnIndex(DbHelper.KEY_ID)));
              user_fName.add(mCursor.getString(mCursor.getColumnIndex(DbHelper.KEY_FNAME)));
              user_lName.add(mCursor.getString(mCursor.getColumnIndex(DbHelper.KEY_LNAME)));
              user_eMail.add(mCursor.getString(mCursor.getColumnIndex(DbHelper.KEY_EMAIL)));
              user_cHeck.add(mCursor.getString(mCursor.getColumnIndex(DbHelper.KEY_CHECK)));
  
          } while (mCursor.moveToNext());
      }
      DisplayAdapter disadpt = new DisplayAdapter(getActivity(),userId, user_fName, user_lName, user_eMail, user_cHeck);
      userList.setAdapter(disadpt);
      mCursor.close();
  }
  {
  
  }
  </code></pre>
  
  <p>On creation i receive the following error:</p>
  
  <pre><code>04-09 15:33:16.740: E/SQLiteLog(19806): (1) near "TEXT": syntax error
  04-09 15:33:16.755: W/dalvikvm(19806): threadid=1: thread exiting with uncaught exception (group=0x40df4a08)
  04-09 15:33:16.765: E/AndroidRuntime(19806): FATAL EXCEPTION: main
  04-09 15:33:16.765: E/AndroidRuntime(19806): android.database.sqlite.SQLiteException: near "TEXT": syntax error (code 1): , while compiling: CREATE TABLE user (id INTEGER PRIMARY KEY, fname TEXT, lname TEXT, check TEXT)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:909)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:520)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteStatement.&lt;init&gt;(SQLiteStatement.java:31)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1719)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1650)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at app.norman.tennis.fours.DbHelper.onCreate(DbHelper.java:23)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at app.norman.tennis.FoursFragment.displayData(FoursFragment.java:244)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at app.norman.tennis.FoursFragment.onResume(FoursFragment.java:235)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.Fragment.performResume(Fragment.java:1828)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:921)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.BackStackRecord.run(BackStackRecord.java:682)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1437)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.os.Handler.handleCallback(Handler.java:725)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.os.Handler.dispatchMessage(Handler.java:92)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.os.Looper.loop(Looper.java:158)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at android.app.ActivityThread.main(ActivityThread.java:5751)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at java.lang.reflect.Method.invoke(Method.java:511)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
  04-09 15:33:16.765: E/AndroidRuntime(19806):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Can anyone help me understand why i am having this problem. Thanks in advance.</p>