title: Sqlite error code 1, msg syntax error
body: <p>From what I can tell, it seems like it is passing the addTask contentvalues in the wrong order, but I do not see why. The addUser method is implemented in the same way and works fine.</p>
  <p>The error that I get and all relevant code is here. Any help is appreciated.</p>
  <blockquote>
  <p>04-05 23:09:37.465: I/SqliteDatabaseCpp(606): sqlite returned: error code = 1, msg = near &gt;&quot;id&quot;: syntax error, db=/data/data/edu.flying.panda.taskmanager/databases/dbManager</p>
  <p>04-05 23:09:37.545: E/SQLiteDatabase(606): Error inserting detail=
  type=SCHOOL date= location= user id=1 description=sdfg completed=false</p>
  <p>04-05 23:09:37.545: E/SQLiteDatabase(606):
  android.database.sqlite.SQLiteException: near &quot;id&quot;: syntax error: ,
  while compiling: INSERT INTO tasks(detail,type,date,location,user
  id,description,completed) VALUES (?,?,?,?,?,?,?)</p>
  </blockquote>
  <pre><code>package edu.flying.panda.taskmanager;
  
  import java.util.ArrayList;
  import java.util.List;
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;
  
  public class DatabaseHandler extends SQLiteOpenHelper {
      // current user id
      private static int CURRENT_USER_ID;
      // db version
      private static final int DATABASE_VERSION = 1;
      // db name
      private static final String DATABASE_NAME = &quot;dbManager&quot;;
      // table name
      private static final String TABLE_USERS = &quot;users&quot;;
      private static final String TABLE_TASKS = &quot;tasks&quot;;
      // user table column names
      private static final String USER_KEY_ID = &quot;id&quot;;
      private static final String USER_KEY_USERNAME = &quot;username&quot;;
      private static final String USER_KEY_PASSWORD = &quot;password&quot;;
      private static final String USER_KEY_NAME = &quot;name&quot;;
      private static final String USER_KEY_EMAIL = &quot;email&quot;;
      // task table column names
      private static final String TASK_KEY_ID = &quot;id&quot;;
      private static final String TASK_KEY_USERID = &quot;user id&quot;;
      private static final String TASK_KEY_DESCRIPTION = &quot;description&quot;;
      private static final String TASK_KEY_LOCATION = &quot;location&quot;;
      private static final String TASK_KEY_DATE = &quot;date&quot;;
      private static final String TASK_KEY_DETAIL = &quot;detail&quot;;
      private static final String TASK_KEY_TYPE = &quot;type&quot;;
      private static final String TASK_KEY_COMPLETED = &quot;completed&quot;;
      
      
      // constructor
      public DatabaseHandler(Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
      }
      // Creating Tables
      @Override
      public void onCreate(SQLiteDatabase db) {
          String CREATE_USERS_TABLE = 
                  String.format(&quot;CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s TEXT, %s TEXT, %s TEXT, %s TEXT);&quot;,
                          TABLE_USERS, USER_KEY_ID, USER_KEY_USERNAME, USER_KEY_PASSWORD,
                          USER_KEY_NAME, USER_KEY_EMAIL);
          String CREATE_TASKS_TABLE =
                  String.format(&quot;CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER, %s TEXT, %s TEXT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER);&quot;,
                          TABLE_TASKS, TASK_KEY_ID, TASK_KEY_USERID, TASK_KEY_DESCRIPTION, TASK_KEY_LOCATION, TASK_KEY_DATE, TASK_KEY_DETAIL, TASK_KEY_TYPE, TASK_KEY_COMPLETED);
          
          db.execSQL(CREATE_TASKS_TABLE);
          db.execSQL(CREATE_USERS_TABLE);
          
      }
      // Upgrading database
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          // Drop older table if existed
          db.execSQL(&quot;DROP TABLE IF EXISTS &quot; + TABLE_USERS);
          db.execSQL(&quot;DROP TABLE IF EXISTS &quot; + TABLE_TASKS);
          // Create tables again
          onCreate(db);
      }
      public void addUser(User user) {
          SQLiteDatabase db = this.getWritableDatabase();
  
          ContentValues values = new ContentValues();
          values.put(USER_KEY_USERNAME, user.getUsername());
          values.put(USER_KEY_PASSWORD, user.getPassword());
          values.put(USER_KEY_NAME, user.getName());
          values.put(USER_KEY_EMAIL, user.getEmail());
  
          // inserting row
          db.insert(TABLE_USERS, null, values);
          db.close();
      }
      
      public void addTask(Task task){
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues values = new ContentValues();
      
      values.put(TASK_KEY_USERID, getCURRENT_USERID());
      values.put(TASK_KEY_DESCRIPTION, task.getDescription() );
      values.put(TASK_KEY_LOCATION, task.getLocation() );
      values.put(TASK_KEY_DATE, task.getDueDate());
      values.put(TASK_KEY_DETAIL, task.getDetailedDescription() );
      values.put(TASK_KEY_TYPE, task.getType() );
      values.put(TASK_KEY_COMPLETED,  task.isCompleted());
      
      db.insert(TABLE_TASKS, null, values);
      db.close();     
  }
      
      
      
      
      
      
      
      
  
  }
  </code></pre>