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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:39:15+00:00 2026-06-01T10:39:15+00:00

Cursor ca2 = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, null, null, null, null, null); int countTotal = ca2.getCount();

  • 0
 Cursor ca2 = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, null,     null, null, null, null);
 int countTotal = ca2.getCount();
 Cursor ca1 = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, DatabaseHelper.VALUE6 + "='Automatic'", null, null, null, null);
 int count = ca1.getCount();

 int percentTrans = ((count/countTotal)*100);
 statText=(EditText)findViewById(R.id.etext3);
 statText.setText(Integer.toString(percentTrans));

 Toast toast=Toast.makeText(this, Integer.toString(percentTrans), 2000);
 toast.show();

Hello , i have a silly problem here. I want to the percentage by dividing count over countTotal and multiplying that by 100. percentTrans is integer by nature and this value will be passed to an edit text which requires that percentTrans be converted to string. count is 2 and countTotal is 3. But i get 0 as the result. Any ideas?

  • 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-01T10:39:16+00:00Added an answer on June 1, 2026 at 10:39 am

    count/countTotal is int too and (int)(2/3) is 0.

    write it as (count*100/countTotal)

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

Sidebar

Related Questions

I am trying this Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); Cursor cursor1
Cursor cursor = resolver.query( Data.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] {String.valueOf(rawContactId)}, null); With PROJECTION being:
// get friends public Cursor getFriends(){ Cursor c = dataBase.query(SqConstants.FRIENDS_TABLE_LOCAL, null, null, null, null,
private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection =
I have the cursor with the query statement as follows: cursor.execute(select rowid from components
Cursor findNormalItems = db.query(items, columns, type=?, new String[] { onSale }); I want to
public Cursor fetchTimetable() { return mDb.query(DATABASE_TABLE_TIMETABLE, new String[] {TIMETABLE_ROWID, TIMETABLE_MODULECODE, TIMETABLE_MODULENAME, TIMETABLE_ROOM, TIMETABLE_LECTURER, TIMETABLE_TIME},
Cursor mCursor = mDb.query(true, CUSTOMER_TABLE_NAME, new String[] {GENERIC_ID_KEY, ADDRESS_KEY, PHONE_KEY, EMAIL_KEY,CUSTOMER_NAME_KEY}, GENERIC_ID_KEY + =
Cursor API tells that the behavior is defined by the implementation when a null
cursor.execute(SELECT user_id FROM myapp_location WHERE\ GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < %s\ ,(user_utm_easting, user_utm_northing, 500)); 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.