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 8259295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:49:35+00:00 2026-06-08T02:49:35+00:00

I built a DB using SQLite and when I try to run my main

  • 0

I built a DB using SQLite and when I try to run my main activity file which populates the DB it crashes on onCreate. I doesn’t get to load the activity. My onCreate method opens a db using getWriteableDatabase and from I just add the values className, workoutName, and id to the table I have created which execpts these values. For some reason my activity won’t even load. Any ideas?

Below is my code:

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class poetry3 extends Activity {

Button next;
ClassName addName;
Preference prefs;
DBHelper1 dbHelper;
SQLiteDatabase db;

@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.poetry3);
    dbHelper = new DBHelper1(this);
    String className = "edu.njit.hss.poetry3";
    String workoutName = "Poetry 3";
    Calendar currentDate =  Calendar.getInstance();
    String date = currentDate.getTime().toString();

    int classID = 1;


    db = dbHelper.getWritableDatabase();
    ContentValues values = new ContentValues();


    //if(values.size() >  25)

    values.clear();
    values.put(DBHelper1.C_ID, classID);
    values.put(DBHelper1.C_CLASSNAME, className);
    values.put(DBHelper1.C_WORKOUT_NAME, workoutName);
    values.put(DBHelper1.C_CREATED_AT, date);
    db.insertOrThrow(DBHelper1.TABLE, null, values);



    next = (Button)findViewById(R.id.Continue);
    next.setOnClickListener(phaseHandler);

}

View.OnClickListener phaseHandler = new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if(next.getId() == ((Button)v).getId()){
            Intent i = new Intent(poetry3.this, poetry5.class);
            startActivity(i);
        }

    }
};

    }

Here is the logcat output:

07-21 18:57:26.628: ERROR/AndroidRuntime(695): FATAL EXCEPTION: main
07-21 18:57:26.628: ERROR/AndroidRuntime(695): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.njit.hss/edu.njit.hss.poetry3}: android.database.sqlite.SQLiteException: near "at": syntax error: , while compiling: INSERT INTO history(workout_name, created at, _ID, classname) VALUES(?, ?, ?, ?);
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.os.Looper.loop(Looper.java:123)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.main(ActivityThread.java:3647)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invokeNative(Native Method)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invoke(Method.java:507)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at dalvik.system.NativeStart.main(Native Method)
07-21 18:57:26.628: ERROR/AndroidRuntime(695): Caused by: android.database.sqlite.SQLiteException: near "at": syntax error: , while compiling: INSERT INTO history(workout_name, created at, _ID, classname) VALUES(?, ?, ?, ?);
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1549)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1444)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at edu.njit.hss.poetry3.onCreate(poetry3.java:49)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
07-21 18:57:26.628: ERROR/AndroidRuntime(695):     ... 11 more
07-21 18:57:26.658: WARN/ActivityManager(39):   Force finishing activity edu.njit.hss/.poetry3
  • 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-08T02:49:36+00:00Added an answer on June 8, 2026 at 2:49 am

    The error is in your database’s create table statement (in DBHelper1.onCreate()):

    create table history(BaseColumns._ID int primary key, classname text workout_nametext)
    

    If you are trying to reference the id in a ContentProvider (like ContactsContract, CalendarContract, etc) understand that BaseColumns._ID means something very different in SQL; you’re also missing a comma and a space. I assume you meant:

    create table history(_id integer primary key, classname text, workout_name text)
    

    If you post the string where you create your SQLite database and I can be more specific about the syntax…

    String table_create = "create table " + table_name + " (" + BaseColumns._ID + ...
    

    New LogCat

    To read a LogCat often you want to find the lowest “Caused by”, in this case:

    Caused by: android.database.sqlite.SQLiteException: near "at": syntax error: , while compiling: INSERT INTO history(workout_name, created at, _ID, classname) VALUES(?, ?, ?, ?);
    

    This happens in poetry3.onCreate(), specifically on line 49.

    Here you can see that “created at” causes the error, SQLite defines variable as one word names, perhaps you meant created_at? But your create statement only has three columns, so I would just remove it:

    INSERT INTO history(_ID, classname, workout_name) VALUES(?, ?, ?, ?);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a sqlite db which I am manipulating using qts built in
I have an application built using JSF1.2. I have a home page which has
I've got a WebForms site built using Progressive Enhancement which uses Master pages. Obviously,
I need to trigger an executable file(built using .net) using the command prompt. For
I have been using the System.Data.SQLite provider for my application. When I try to
I'm using the built in sqlite library on the Android platform. I'm considering adding
I am using this as a resource to get me started - http://www.pantz.org/software/sqlite/sqlite_commands_and_general_usage.html Currently
I have a problem which I will try to reproduce: 1)I get a SSH
I have a problem with SQLite. When I try to insert entries I get
My website is built using php files. I use trade secret algorithms in these

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.