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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:48:42+00:00 2026-06-04T20:48:42+00:00

I am trying to insert rows into a database when the database is first

  • 0

I am trying to insert rows into a database when the database is first created.

@Override
    public void onCreate(SQLiteDatabase db) {
        // Only uses this method when the database is first created.
        //Sets up the database - telling it the table name and all
        //the column names.
        db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" + 
                KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                KEY_REPS + " TEXT NOT NULL, " +
                KEY_ABS + " TEXT NOT NULL);"    
        );

        db.execSQL("INSERT INTO DATABASE_TABLE(KEY_REPS, KEY_ABS) VALUES ('25', 'Reverse Crunches' );" );
        db.execSQL("INSERT INTO DATABASE_TABLE(KEY_REPS, KEY_ABS) VALUES ('25', 'Crunches' );" );
        db.execSQL("INSERT INTO DATABASE_TABLE(KEY_REPS, KEY_ABS) VALUES ('1 minutes', 'Plank' );" );
        db.execSQL("INSERT INTO DATABASE_TABLE(KEY_REPS, KEY_ABS) VALUES ('30', 'Toe Touches' );" );
        db.execSQL("INSERT INTO DATABASE_TABLE(KEY_REPS, KEY_ABS) VALUES ('50', 'Russian Twists' );" );

    }

If I do not have the insert calls in there the database creates fine, and I can add to it, view it, etc. However, for some reason when I try putting the calls to insert the data on create I get an error “no such table”.

I tried putting the insert calls into a separate method called Populate, and calling that in my main activity, but that also produces an error.

Not sure what I am doing wrong. Any help would be greatly appreciated.

  • 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-04T20:48:43+00:00Added an answer on June 4, 2026 at 8:48 pm

    Instead of using the string that names your table(represented by the DATABASE_TABLE String variable) your using the string "DATABASE_TABLE" directly(which means nothing to the database as you don’t have a table DATABASE_TABLE). Update your insert calls like this:

    db.execSQL("INSERT INTO " + DATABASE_TABLE + "(" + KEY_REPS +", " + KEY_ABS + ") VALUES ('25', 'Reverse Crunches' );" );
    

    and the same for the other insert call as well(look how you declared the creation sql String).
    After you make this modifications, uninstall your app and reinstall it again so the changes are seen by the SQLiteOpenHelper.

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

Sidebar

Related Questions

During onCreate() I'm trying to insert about 20 rows into the SQLite database (these
I'm trying to insert multiple rows into MySql with only one INSERT INTO statement
I'm trying to INSERT INTO a mySQL database and I'm getting this error on:
I am trying to insert rows into a MySQL database from an Access database
I am trying to insert rows into a SQLite database within Android. A call
I am trying to insert over 70,000 rows into a javascript database (using Chrome
I am trying to insert into mysql database dynamically. But I always see only
I am trying to put this into the database. All rows are correct. Each
I am trying to insert thousands of rows into a table and performance is
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get

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.