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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:51:20+00:00 2026-05-25T22:51:20+00:00

I’ve got the following code to get a sum of real values (debt amounts

  • 0

I’ve got the following code to get a sum of real values (debt amounts stored in an SQlite DB:

public double getsumdebt() {
        Cursor mCursor = db.rawQuery("SELECT SUM(CurrentAmount) FROM tblDebts", null);
        if(mCursor.moveToFirst()) {
        return mCursor.getDouble(0);
    }
    return mCursor.getDouble(0);
    }

I am trying to return the sum of all the values in the “CurrentAmount” column and display it in a textview:

 DbAdapter db2 = new DbAdapter(this);
 double sum= new Double(db2.getsumdebt());
 //sum = db2.getsumdebt();
  bar.setText("Progress: "+currencysymbol +current +" / " + currencysymbol + sum);

however, when I run the app in the emulator, I get a Force close during launch, with the following in the DDMS log:

09-26 19:01:19.098: ERROR/AndroidRuntime(677): FATAL EXCEPTION: main
09-26 19:01:19.098: ERROR/AndroidRuntime(677): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.evanrich.android.debtdestroyer/com.evanrich.android.debtdestroyer.mainActivity}: java.lang.NullPointerException
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.os.Looper.loop(Looper.java:123)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at java.lang.reflect.Method.invoke(Method.java:521)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at dalvik.system.NativeStart.main(Native Method)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): Caused by: java.lang.NullPointerException
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at com.evanrich.android.debtdestroyer.database.DbAdapter.getsumdebt(DbAdapter.java:106)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at com.evanrich.android.debtdestroyer.mainActivity.onCreate(mainActivity.java:73)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-26 19:01:19.098: ERROR/AndroidRuntime(677): … 11 more

It looks like it’s not able to sum the real values stored in the DB. Can anyone help me?

FYI, this is my table constructor:

private static final String DATABASE_CREATE =
    "CREATE TABLE IF NOT EXISTS tblDebts (_id integer primary key autoincrement, "
    + "Debt text not null, StartingAmount real, CurrentAmount real, " 
    + "InterestRate real, DueDate integer, MinimumPayment real );";

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-05-25T22:51:21+00:00Added an answer on May 25, 2026 at 10:51 pm

    You have an NPE

    19:01:19.098: ERROR/AndroidRuntime(677): Caused by: java.lang.NullPointerException 09-26 19:01:19.098: ERROR/AndroidRuntime(677): at com.evanrich.android.debtdestroyer.database.DbAdapter.getsumdebt(DbAdapter.java:106) 09-26

    Which is line 106?

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i got an object with contents of html markup in it, for example: string
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.