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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:19:09+00:00 2026-05-27T03:19:09+00:00

I am attempting to enter values such as 0.20 within a table but when

  • 0

I am attempting to enter values such as “0.20” within a table but when I display it within an activity it shows “0.2”. I am uncertain as to why the ‘0’ is being removed i.e. incorrect structure of the table, insertion, or being returned.

My table is created as followed:

db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" + KEY_ROWID
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_NAME
                + " TEXT NOT NULL, " + KEY_SWIMMERLAPS + " INT NOT NULL, "
                + KEY_SPONSOR + " DEC(4,2) NOT NULL );");

I then insert the data:

public long addSwimmer(String name, String laps, String sponsor) {
    int i = Integer.parseInt(laps);
    ContentValues cv = new ContentValues();
    cv.put(KEY_NAME, name);
    cv.put(KEY_SWIMMERLAPS, i);
    cv.put(KEY_SPONSOR, (new DecimalFormat("0.00##")).format(0.20));
    return ourDatabase.insert(DATABASE_TABLE, null, cv);
}

and then return the sponsorship data:

public String getSwimmerSponsors() {
    String[] columns = new String[] { KEY_SPONSOR };
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null,
            null, KEY_SWIMMERLAPS + " DESC");
    String result = "";

    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
        result = result + c.getString(0) + "\n";
    }
    return result;
}

Edit – I display the returned result in my layout as follows:

String sponsors = swimmerDb.getSwimmerSponsors();
    tvSponsor.setText(sponsors);

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-27T03:19:10+00:00Added an answer on May 27, 2026 at 3:19 am

    Because you’re displaying an unformatted Java variable, and leading/trailing 0s are suppressed.

    If you want to format it with a specific layout, use one of the printf/format variants:

    printf("%.2f", num); // Etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a form where a user is able to enter
Attempting to insert an escape character into a table results in a warning. For
Attempting to print out a list of values from 2 different variables that are
I am attempting to learn Ruby by converting a Java program to Ruby, but
I create a form wherein the user enters some values but I now need
We have a multi-line control that we are attempting to prevent the Enter/Return key
I am just attempting to use the java keytool but I cannot figure out
I'm attempting to check the values entered by a user into an input text
I am attempting to format an entire column of a table by replacing the
I am attempting to make some reports in Excel using a pivot table 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.