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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:53:23+00:00 2026-06-07T21:53:23+00:00

I have a working database in my android application. I can add rows without

  • 0

I have a working database in my android application. I can add rows without a problem. But when I try to update a row, the database puts the wrong values in the columns.

I have gone through the code plenty of times but I can’t find the problem, I probably looked at it so much that I can’t see the obvious problem. The problem is that when updating the database row. the values get put in the wrong column. Every column gets filled with the new data. but they are not in the correct column.

Here is an example:

// Inserting row into database gives this correct result
example: | id | column1 | column2 | column3 | column4 | column5 |
         | 1  | value1  | value2  | value3  | value4  | value5  |

// after updating the row i get this bad result:
example: | id | column1 | column2 | column3 | column4 | column5 |
         | 1  | value1  | value2  | value5  | value3  | value4  |

I have a listview shows the database column1´s value, then send the rest of the columns to another activity. think of it as a contact list in the listview and when clicking on a contact the rest of the information is show.

I send the data with this:

      EditContact.putExtra(MyContacts.ROW_ID, rowID);
      EditContact.putExtra("PHONE", phoneTextView.getText());
      EditContact.putExtra("EMAIL", emailTextView.getText());
      EditContact.putExtra("ADRESS", adressTextView.getText());          
      EditContact.putExtra("NAME", nameTextView.getText());
      EditContact.putExtra("COMMENT", commentTextView.getText());
      startActivity(EditContact); // start the Activity

in the EditContact activity i get the information like this and put the information in EditTexts.

    if (extras != null) {
        rowID = extras.getLong("row_id");
        phoneEditText.setText(extras.getString("PHONE"));
        emailEditText.setText(extras.getString("EMAIL"));
        adressEditText.setText(extras.getString("ADRESS"));
        nameEditText.setText(extras.getString("NAME"));
        commentEditText.setText(extras.getString("COMMENT"));
    }

I then save the information in the database like this:

         String phone   =   phoneEditText.getText().toString();
         String email   =   emailEditText.getText().toString();
         String adress  =   adressEditText.getText().toString(); 
         String name    =   nameEditText.getText().toString();
         String comment =   commentEditText.getText().toString();                 
     String spinner1 = (String) spinner1.getSelectedItem();
     String spinner2 = (String) spinner2.getSelectedItem();
     String spinner3 = (String) spinner3.getSelectedItem();

 databaseConnector.updateContact(rowID, spinner1, spinner2, spinner3, phone, email, adress, name, comment);

As you see I have three spinners here. I also have that when I add contact to database. and they gets inserted into the correct column even after update. these spinners gets translated to text in the viewcontact activity.

This is how I update the database in the DatabaseConnector

public void updateContact(long id, String spinner1, String spinner2, String spinner 3, String phone, String email, String adress, String name, String comment)
{
    ContentValues editContact = new ContentValues();
    editContact .put("SPINNER1", spinner1);
    editContact .put("SPINNER2", spinner2);
    editContact .put("SPINNER3", spinner3);
    editContact .put("PHONE", phone);
    editContact .put("EMAIL", email);
    editContact .put("ADRESS", adress);
    editContact .put("NAME", name);
    editContact .put("COMMENT", comment);

    open();
    database.update(DATABASE_TABLE, editContact , "_id=" + id, null);
    close();
} 

I would really appreciate if someone have any idea of what could be wrong. I simply can not see it. Although I’m new at this and still learning. Thank you

every value gets inserted into the correct row that I’m editing. but in the wrong column, and I get no errors.

  • 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-07T21:53:25+00:00Added an answer on June 7, 2026 at 9:53 pm

    Be sure that your order of columns is correct. Are you sure that your table layout goes _id, SPINNER1, SPINNER2, SPINNER3, phone, email, address, name comment? What is the code for database.update? The order will likely matter. The code can’t just figure out the correct order of things based on magic 😉

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

Sidebar

Related Questions

i am working on an android database application and have fired query like this
I have an Android application that installs a database (~2000 rows across all tables)
I'm working on an application which uses SQLite Database on Android.I have a custom
I'm developing this Android application where users can update their SQLite database to the
I am working on an android app and have to use remote database for
I have been working on VB6 database desktop programming, but now a client is
I have been working with iPhone application in which i am using sqlite database.
I'm working on my first android application and running into an issue I can't
I am working on designing an Android application, and I have several questions I
I have one problem with Android SQLite database. I have one table which contains

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.