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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:29:29+00:00 2026-06-16T00:29:29+00:00

Whenever I use the following code to insert multiple records into a table it

  • 0

Whenever I use the following code to insert multiple records into a table it only inserts the last initialized value.

Here’s the method for inserting data into a table:

public long insertQuote() {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_PHID, 100);
        initialValues.put(KEY_LAT, 28.5700);
        initialValues.put(KEY_LAT, 28.4700);
        initialValues.put(KEY_LAT, 27.1833);
        initialValues.put(KEY_LAT, 26.4583);

        initialValues.put(KEY_LON, 77.3200);
        initialValues.put(KEY_LON, 77.0300);
        initialValues.put(KEY_LON, 78.0167);
        initialValues.put(KEY_LON, 80.3173);

        return db.insert(DATABASE_TABLE, null, initialValues);
    }

In this case for the column key “KEY_LAT” I am only able to see the last initialized value “26.4583” on a S.O.P (Sys.out.println) output on logcat.

Same follows for the other column key “KEY_LON”. I can see just these two records.

I suppose they’re not inserted into the table as put() Method skips the previously "to-be-inserted" values and accepts the last for a particular column.

Any help is appreciated. Thanks.

  • 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-16T00:29:30+00:00Added an answer on June 16, 2026 at 12:29 am

    This is happening because you are using same key LAT and LON for all. That’s being overwritten.

    You should use different keys such as

    public long insertQuote() {
            ContentValues initialValues = new ContentValues();
            initialValues.put(KEY_PHID, 100);
            initialValues.put(KEY_LAT1, 28.5700);
            initialValues.put(KEY_LAT2, 28.4700);
            initialValues.put(KEY_LAT3, 27.1833);
            initialValues.put(KEY_LAT4, 26.4583);
    
            initialValues.put(KEY_LON1, 77.3200);
            initialValues.put(KEY_LON2, 77.0300);
            initialValues.put(KEY_LON3, 78.0167);
            initialValues.put(KEY_LON4, 80.3173);
    
            return db.insert(DATABASE_TABLE, null, initialValues);
        }
    

    Edit:

    So you should use this approach.

    public long insertQuote() {
                ContentValues initialValues = new ContentValues();
                initialValues.put(KEY_PHID, 100);
                initialValues.put(KEY_LAT, 28.5700);
                initialValues.put(KEY_LON, 77.3200);
                db.insert(DATABASE_TABLE, null, initialValues);
                initialValues.put(KEY_LAT, 28.4700);
                initialValues.put(KEY_LON, 77.0300);
                db.insert(DATABASE_TABLE, null, initialValues);
                initialValues.put(KEY_LAT, 27.1833);
                initialValues.put(KEY_LON, 78.0167);
                db.insert(DATABASE_TABLE, null, initialValues);
                initialValues.put(KEY_LAT, 26.4583);
                initialValues.put(KEY_LON, 80.3173);
                return db.insert(DATABASE_TABLE, null, initialValues);  
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I use the following code, the webserver (running IIS 7) refuses to send
whenever I use the following code in PHP files , it gives me the
The following code segfaults whenever I use short-circuit-or ( | ), and compiles flawlessly
I want to use the following code to find a user's location in multiple
I use the following event in JavaScript for page load.whenever the page is closed
I started getting the following error whenever i use SVN in my server: svn:
Whenever I want to get data from a plist file I use the following
Whenever I use the Eclipse source code formatter / beautifier (via the menu item
I use the following code to open external pages within a div on the
I use the following MSDN code on my master page to detect if the

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.