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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:39:30+00:00 2026-05-24T10:39:30+00:00

I have created a database for my app with 5 columns. Each column only

  • 0

I have created a database for my app with 5 columns. Each column only consists of integers.

At first, the table is empty. Now, if I add the values {1, 2, 3} to the first column (column1), I would like it too look like this:

http://pastebin.com/ZiUfDVEV

But in reality, it looks like this:

http://pastebin.com/zff926Zh

That is, it has inserted unwanted zeros at places to which I didn’t add new values.

I have tried two different ways of inserting values into the database.

First way:

DBAdapter db = new DBAdapter(this);
int[] sdTest = new int[] {1,2,3};
storeIDs(db, sdTest);

public void storeIDs(DBAdapter db, int[] ids)
{
    db.open();
    long id;
    for(int i=0; i<ids.length; i++)
    {
        id = db.insertIDs(ids[i]);          
    }        
    db.close();
}

And this method from the DBAdapter class:

public long insertIDs(int sd)
{
    ContentValues initialValues = new ContentValues();
    initialValues.put(SD, sd);
    return db.insert(DATABASE_TABLE, null, initialValues);
}

(where SD is the column name of the first column.)

Second way:

DBAdapter db = new DBAdapter(this);
int[] sdTest2 = new int[] {1,2,3};
storeIDsExe(db, sdTest2);

public void storeIDsExe(DBAdapter db, int[] ids)
{
    db.open();
    for(int i=0; i<ids.length; i++)
    {
        db.insertIDsExe(ids[i]);            
    }        
    db.close();     
}

And this method from the DBAdapter class:

public void insertIDsExe(int sd)
{
    db.execSQL("INSERT INTO "
            + DATABASE_TABLE
            + " (column1)"
            + " VALUES ("+sd+");");
}

Both ways give the same result: unwanted zeros.

How to get rid of them?

edit:

The table is created like so:

private static final String DATABASE_CREATE =
    "CREATE TABLE IF NOT EXISTS "
    + DATABASE_TABLE
    + " (column1 int, column2 int, column3 int, column4 int, column5 int);";
  • 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-05-24T10:39:30+00:00Added an answer on May 24, 2026 at 10:39 am

    Does your table define default values for the columns? Columns should have attribute DEFAULT NULL :

    EDIT

    I have just tested it, in-memory sqlite db with Firefox SQLiteManager. It works.

    CREATE TABLE IF NOT EXISTS test (column1 int NULL DEFAULT NULL, 
       column2 int NULL DEFAULT NULL, 
       column3 int NULL DEFAULT NULL, 
       column4 int NULL DEFAULT NULL, 
       column5 int NULL DEFAULT NULL);
    

    and then

    INSERT INTO test(column1) VALUES (4);
    

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

Sidebar

Related Questions

In my iPhone app, I have created index on Sqlite database table for some
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I want to have one table with two TIMESTAMP columns. One column to keep
I have a mysql database table called character with columns like name, strength, intelligence,
I am trying to import an access database to mysql. I have created a
I have a regex created from a list in a database to match names
I have an Oracle database backup file (.dmp) that was created with expdp .
I have designed database tables (normalised, on an MS SQL server) and created a
I have a batch file that was created for an Oracle database that I'm
I am building an asp.net MVC2 web app using StructureMap. I have created a

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.