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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:29:44+00:00 2026-06-04T11:29:44+00:00

My question is how to you call a method like this. I already know

  • 0

My question is how to you call a method like this. I already know how to implement it. Here is the method content:

 public boolean updateDebt(long updateId, String debtName, String debtTotal,
        String debtApr, String paymentGoal) {

     ContentValues values = new ContentValues();
     values.put(MySQLiteHelper.COLUMN_DEBT_NAME, debtName);
     values.put(MySQLiteHelper.COLUMN_DEBT_TOTAL, debtTotal);
     values.put(MySQLiteHelper.COLUMN_APR, debtApr);
     values.put(MySQLiteHelper.COLUMN_PAYMENT, paymentGoal);
     String whereClause = MySQLiteHelper.COLUMN_ID + " = ?";
     String[] whereArgs = new String[]{ String.valueOf(updateId) };
     return database.update(MySQLiteHelper.TABLE_DEBT, values, whereClause, whereArgs) > 0;

My questions lies in calling this updateDebt Method.

Picture a dialog with four fields with an update button. The fields are pre-populated with table data. The user changes field data and hits update, the table should change.

This is the code that comes before the call. Keep in mind, I am calling it via an onClick inside a dialog inside an onListItemClick.

(I’ve edit lots of unrelated stuff out)

List<Debt> values;
MyArrayAdapter adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.debts);

    datasource = new DebtDataSource(this);
    datasource.open();
    values = datasource.getAllDebt();
    adapter = new MyArrayAdapter(this, values);
    setListAdapter(adapter);

  }

 protected void onListItemClick(ListView l, View v, final int position, long id) {

    Debt item = values.get(position);

    final long boxId = item.getId();
    final String BoxName = item.getName();
    final String BoxBalance = item.getBalance();
    final String BoxApr = item.getApr();
    final String BoxPayment = item.getPayment();

 // (edited out: setting up EditText fields here with data from above)

    // set up button
    Button button = (Button) dialog.findViewById(R.id.button1);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {


            datasource.updateDebt(Long.valueOf(boxId), BoxName, BoxBalance,
                    BoxApr, BoxPayment);
            values = datasource.getAllDebt();
            adapter.notifyDataSetChanged();
            dialog.dismiss();

        }
    });

    dialog.show();
}

Simply put nothing happens when I hit update. The dialog dismisses, that’ it. Nothing in logcat. I have logged out the variables just before the update method inside the updateDebt() method. I have toasted them back and all the variables match up perfectly. The database doesn’t change though!
Struggling on this for days….

  • 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-04T11:29:45+00:00Added an answer on June 4, 2026 at 11:29 am

    I finally figured out the answer. This is what I WAS doing:

    1. Creating a String variable for each column in a specific row of debt.
    2. Pre-populating the fields in the dialog with that variable.
    3. Then passing the same variables into the update method

    For example (simplified):

     String name = null;
     EditText et;
    
     name = debt.getName();
     et.setText(name);
    
     onclick {
         datasource.updateDebt(name);
     }
    

    I was missing a step between 2 and 3.
    Setting the variable again, inside the onClick method. Once the user pressed the update button, the variable had to be RE-SET to the new value of the EditText field. Like this:

     String name = null;
     EditText et;
    
     name = debt.getName();
     et.setText(name);
     onclick {
         ***name = et.getText().toString();***
         datasource.updateDebt(name);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an objective-c question. I would like to call a method in an
Just a quick question. Say a call a method like so mysql_pconnect(server,tator_w,password) or die(Unable
Quick question, is there a way to call your main method whatever you like
This is hopefully a softball syntax question: I need to call a method with
I have this question: How could I call a codebehind method from jquery? I
the title already tells the question: you can successfully call the Print-Method on a
I'm sure that someone already posted this question; however, I would like to get
I know I asked this question already many times, but I did not get
I'm not sure what to call this question, since it involves a variety of
I admit this question is getting to the limits of what I know of

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.