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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:42:09+00:00 2026-06-16T19:42:09+00:00

This is a strange problem, and I hope it has a simple solution. I

  • 0

This is a strange problem, and I hope it has a simple solution. I have a database with encrypted values. I have created a cursor that will go through each of the entries in a table, decrypt the value from the column I need, and add the value to a variable, “total”. I want the sum of all of the values in the column. Here is the code:

while (c.moveToNext())
      {           
            strTotal = c.getString(c.getColumnIndexOrThrow(KEY_TOTAL));
            strTotal = sc.decrypt(strTotal);
            total = Float.valueOf(strTotal) + total;             
      }

Now, here’s the strange part. Let’s suppose I have two values in the database: 2 + 4. After each is decrypted, it will correctly add them: 6. Now, if the values are equal: 2 + 2, for instance, the method returns “2” instead of “4”. This happens even if it is off by a decimal (2 + 2.01 = 4.01, but 2 + 2 still outputs 2 for example).

Is there something I am missing here? Thanks!

EDIT:

I’ve changed the code around just to see if the decryption was the problem and it is still giving me the same result:

float total = 0;
String strTotal = "10";
while (c.moveToNext())
      {     
          try {
                //strTotal = sc.decrypt(c.getString(c.getColumnIndex(KEY_TOTAL)));
                total = Float.valueOf(strTotal) + total;
            } catch (Exception e) {
                Log.e(TAG, "exception", e);
            }           
      }

This code is returning “10”, even though there are 3 entries in the database! It looks like if two rows in the database have the same value in the KEY_TOTAL field, it is returning less results. Here is the query:

Cursor c = mDb.query(true, DATABASE_TABLE, new String[] {KEY_TOTAL}, KEY_TYPE + "=" + t, null, null, null, null, null);

If I pull the db and open it with a sqlite browser, and SELECT all of the rows, I am getting 3 still, however.

  • 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-16T19:42:10+00:00Added an answer on June 16, 2026 at 7:42 pm

    I just checked the SQLite documentation for Android (I’m not an Android developer) and I think I found your problem. The first argument to the query method is whether to select distinct rows. Since you’re passing TRUE and you’re only selecting one column, duplicates will be removed from the result, which is not what you want.

    Changing your call to query to the following should fix your issue.

    Cursor c = mDb.query(false, DATABASE_TABLE, new String[] {KEY_TOTAL},
        KEY_TYPE + "=" + t, null, null, null, null, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very strange problem, and I just hope that I can clearly
I have this strange problem. I'm trying to write a simple Hello World java
I have this strange problem. I am retrieving twitters and it works on the
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
Starting from Android 3.2 I have this strange problem. It's very easy to reproduce:
This is a really strange problem, that appears to be somewhat intermittent (although it
I have a strange problem. I do this query in a node.js server using
I've got a strange problem here. I have a winforms panel which programatically has
I have strange problem for which I can't think of a solution. I have
I have a strange problem implementing pl/sql procedure. My procedure has four varchar input

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.