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

  • Home
  • SEARCH
  • 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 7867463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:43:23+00:00 2026-06-03T00:43:23+00:00

I am trying to configure a simple DbHelper, and getting an error while executing.

  • 0

I am trying to configure a simple DbHelper, and getting an error while executing.

The error is:

 SQLiteException near "null": syntax error: , while compiling: INSERT OR REPLACE INTO

I cannot figure out what is the problem?

The DbHelper class is:

    package com.sqlite.test1;

    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;

    public class DbHelper extends SQLiteOpenHelper{


    public static final int DB_VERSION = 1;
    public static final String DB_NAME = "time_storage";
    public static final String DB_TABLE = "timer_data";

    public static final String C_ID = "iderty_id";
    public static final String C_DATE = "date";
      Context context;

    public DbHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists " + DB_TABLE + " (" + C_ID + "integer primary key autoincrement, " 
                    + C_DATE + " text not null );");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE);
        this.onCreate(db);      
    }}

The main class is:

package com.sqlite.test1;

import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;

public class SQlite_test1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    DbHelper dbHelper = new DbHelper(SQlite_test1Activity.this);
    SQLiteDatabase db = dbHelper.getWritableDatabase();

    String variable1 = "this is the first text to database";
    ContentValues values = new ContentValues();
    db.insertWithOnConflict(DbHelper.DB_TABLE, null, values,
            SQLiteDatabase.CONFLICT_REPLACE);
    values.put(DbHelper.C_DATE, variable1);

    db.close();
    dbHelper.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-03T00:43:24+00:00Added an answer on June 3, 2026 at 12:43 am

    You need to put in the values before you do the insert, not after, otherwise you’re not inserting anything. Change this:

    ContentValues values = new ContentValues();
    db.insertWithOnConflict(DbHelper.DB_TABLE, null, values,
            SQLiteDatabase.CONFLICT_REPLACE);
    values.put(DbHelper.C_DATE, variable1);
    

    to this:

    ContentValues values = new ContentValues();
    values.put(DbHelper.C_DATE, variable1);
    db.insertWithOnConflict(DbHelper.DB_TABLE, null, values,
            SQLiteDatabase.CONFLICT_REPLACE);
    

    EDIT

    Found another issue:

    db.execSQL("create table if not exists " + DB_TABLE + " (" + C_ID + "integer primary key autoincrement, " + C_DATE + " text not null );");
    

    The above code is creating a primary key called iderty_idinteger. It should be like this:

    db.execSQL("create table if not exists " + DB_TABLE + " (" + C_ID + " integer primary key autoincrement, " + C_DATE + " text not null );");
    

    Note the space inserted before integer primary…

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

Sidebar

Related Questions

I was trying to configure spring 3.1 and hibernate. I have written a simple
I am trying to configure Spring Security in my simple application. Here is my
I'm trying to build a very simple c++ program in eclipse and I'm getting
I am just starting with Autofac and I am trying to configure a simple
I'm trying to write a simple facebook application using FBML. when I configure my
I'm trying to configure SSL on EC2onrails with no luck. At present I am
I am trying to configure the NCommon NHRepository in my project with Structure Map.
I'm trying to configure a parameterized query to the effect of: SELECT field1 FROM
I'm trying to configure a class with Annotation based configuration in Spring 3, which
I'm trying to configure my .emacs file to work in a Windows, Linux, and

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.