Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:51:39+00:00 2026-06-01T17:51:39+00:00

From what I can tell, it seems like it is passing the addTask contentvalues

  • 0

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.

The error that I get and all relevant code is here. Any help is appreciated.

04-05 23:09:37.465: I/SqliteDatabaseCpp(606): sqlite returned: error code = 1, msg = near >"id": syntax error, db=/data/data/edu.flying.panda.taskmanager/databases/dbManager

04-05 23:09:37.545: E/SQLiteDatabase(606): Error inserting detail=
type=SCHOOL date= location= user id=1 description=sdfg completed=false

04-05 23:09:37.545: E/SQLiteDatabase(606):
android.database.sqlite.SQLiteException: near "id": syntax error: ,
while compiling: INSERT INTO tasks(detail,type,date,location,user
id,description,completed) VALUES (?,?,?,?,?,?,?)

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 = "dbManager";
    // table name
    private static final String TABLE_USERS = "users";
    private static final String TABLE_TASKS = "tasks";
    // user table column names
    private static final String USER_KEY_ID = "id";
    private static final String USER_KEY_USERNAME = "username";
    private static final String USER_KEY_PASSWORD = "password";
    private static final String USER_KEY_NAME = "name";
    private static final String USER_KEY_EMAIL = "email";
    // task table column names
    private static final String TASK_KEY_ID = "id";
    private static final String TASK_KEY_USERID = "user id";
    private static final String TASK_KEY_DESCRIPTION = "description";
    private static final String TASK_KEY_LOCATION = "location";
    private static final String TASK_KEY_DATE = "date";
    private static final String TASK_KEY_DETAIL = "detail";
    private static final String TASK_KEY_TYPE = "type";
    private static final String TASK_KEY_COMPLETED = "completed";
    
    
    // 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("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s TEXT, %s TEXT, %s TEXT, %s TEXT);",
                        TABLE_USERS, USER_KEY_ID, USER_KEY_USERNAME, USER_KEY_PASSWORD,
                        USER_KEY_NAME, USER_KEY_EMAIL);
        String CREATE_TASKS_TABLE =
                String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER, %s TEXT, %s TEXT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER);",
                        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("DROP TABLE IF EXISTS " + TABLE_USERS);
        db.execSQL("DROP TABLE IF EXISTS " + 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();     
}
    
    
    
    
    
    
    
    

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:51:41+00:00Added an answer on June 1, 2026 at 5:51 pm

    The error appears to be in your TASK_KEY_USERID as you have a space in the value. Should it perhaps be an underscore? Another note to add is that android likes your primary key column name to end in “_id”, which yours are just “id”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I tell from the assembly name, or assembly class (or others like
Can anybody tell how to retrieve data from database like that of Facebook's notification
What problems was XML invented to solve? From what I can tell, it seems
so from what i can tell, you have to specify artifacts and working directory
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
NSDecimalNumber is a subclass of NSNumber, and from what I can tell, it implements
i have invoked blackberry calender from my application can anyone tell me how to
I can't tell from the Python documentation whether the re.compile(x) function may throw an
From the question you can probably tell that I don't know much about code!
Can anyone tell me how to quickly copy Files from a mapped network drive?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.