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

The Archive Base Latest Questions

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

Integer c=0; DatabaseHelper dbh1 = new DatabaseHelper(this); Cursor ca = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, null, null,

  • 0
 Integer c=0;

 DatabaseHelper dbh1 = new DatabaseHelper(this);
 Cursor ca = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, null, null, null, null, null);

 while (ca.moveToNext()) 

 { 
     String Ans6 = ca.getString(ca.getColumnIndex(DatabaseHelper.VALUE6));
     if ( Ans6.equals("Automatic"))
      {
       c+=1;
      }  
 }
 String strI = Integer.toString(c);

 Toast toast=Toast.makeText(this, strI, 2000);
 toast.show();

I have a SQlite database setup in android. The table has been successfully set up and I am trying to check values from column VALUE6 if it matches Automatic. The cursor has to go through every row and check the value of VALUE6 in that row and return how many rows have Automatic. Is my code right? any ideas? strI returns 0 every time i run the code.

  • 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:12:04+00:00Added an answer on June 1, 2026 at 10:12 am

    That’s a brute force way of doing it. Why not query for that value and then get the count of the rows in the returned cursor?

    Cursor ca = dbh1.getReadableDatabase().query(DatabaseHelper.TABLE_NAME, null, DatabaseHelper.VALUE6 + "='AUTOMATIC'", null, null, null, null);
    int count = ca.getCount();
    

    Hope this helps!

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

Sidebar

Related Questions

var i : integer; i := 1234567; Given the above, I want the string
i'm a new android developper and i'm getting a null pointer exception when i
Can anyone alter this code to include one integer variable. Not including the database
Integer[] ints = list.toArray(new Integer[]{}); If I remove {} the compiler asks to fill
Integer[] lastExchange = new Integer[nColors]; Integer[] exchangeToAdd = new Integer[nColors]; lastExchange = getValue(); exchangeToAdd
Integer.toString(int); and String.valueOf(int); Which one among the above two methods is the efficient way
Integer n = 5; System.out.println(n) // 5! How can i reproduce this behavior in
Integer i = 127; Integer j = 127; System.out.println(i == j); System.out.println(i.equals(j)); Integer i1
An integer's max value in Java is 2147483647, since Java integers are signed, right?
Dynamic integer will be any number from 0 to 150. i.e. - number returns

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.