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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:18:13+00:00 2026-05-26T10:18:13+00:00

My databases (information to display on a table) are connected to buttons. When they

  • 0

My databases (information to display on a table) are connected to buttons. When they are clicked, the table should show info. The database works, but this is the catcher: It works when I had info already entered from testing. But the database crashes if their is nothing to load. Here is the code:

rentD.open();
Log.d(TAG, "OPENING RENT DATABASE...");
String rentData = rentD.getData();
billAmount.setText("Total: " + nf.format(rentD.getAmountTotal()));
Log.d(TAG, "CLOSING RENT DATABASE...");
rentD.close();
Log.d(TAG, "RENT DATABASE CLOSED");
dataResults.setText(rentData);

So every time I click the RENT button, I get a forced close. After further looking, The problem I found have to do with:

billAmount... nf.format(rentD.getAmountTotal()));

which displays a the amount in money format. So if I replace “rentD.getAmountTotal()” with a String variable, the database works perfectly. Here is the error I recieved from LogCat:

10-26 23:53:40.764: DEBUG/DEBUG(14999): OPENING RENT DATABASE...
10-26 23:53:40.764: DEBUG/AndroidRuntime(14999): Shutting down VM
10-26 23:53:40.764: WARN/dalvikvm(14999): threadid=1: thread exiting with uncaught    exception (group=0x4001d5a0)

Again, the problem seems to be passing data that doesn’t exist yet into the textview.
My end result is to have the program start with no data in it so the user can get to the activities that will populate the table. Any suggestions?

  • 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-26T10:18:14+00:00Added an answer on May 26, 2026 at 10:18 am

    From your comment, I would suggest you drop the DecimalFormat from getAmountTotal() because it does nothing useful (you’re not using the return value of format()), and use this instead:

    public double getAmountTotal() {
        Cursor cursor = ourRDatabase.rawQuery("SELECT SUM(RENT_AMOUNT) FROM rentTable", null);
        if (cursor.moveToFirst()) {
            return cursor.getDouble(0);
        } else {
            return 0; // or another default value of your choice
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've built this little script that searches a table in my database, but for
I'm using sessions to receive my info from my database table... But I'm not
I'm a Engineering student and I'm attending a Database and Information Systems class this
Say I have at database table containing information about a news article in each
As usual, some background information first: Database A (Access database) - Holds a table
I am using DevExpress GridControl to display information from my database through a stored
I have an HTML table that displays information from a database, and one of
I'm trying to develop a table that can be used to edit database information
I am using a table to display data pulled from two database tables. I
I have a huge database. In this Database I have a User-Table. In this

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.