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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:13:49+00:00 2026-06-02T17:13:49+00:00

i have a problem with a cursor. i created a alarm manager that pick

  • 0

i have a problem with a cursor. i created a alarm manager that pick a value to compare with another in looping.

My problem is this: if the cursor is outside of the loop this pick only my first value (if exsist only one value pick only this obviously)…. if the cursor is in the loop, this pick only last value (if exsist only one value pick only this obviously).

how to fix this?

my query:

public Cursor getRegistry2()
    {
        return (getReadableDatabase().query(
            TabRegistry.TABLE_NAME, 
            TabRegistry.COLUMNS, 
            TabRegistry._ID, 
            null,
            null, 
            null, 
            null));

my cursor in service:

 Cursor c5 = databaseHelper.getRegistry2();
                     c5.moveToFirst();
                        while(c5.isAfterLast() == false){   
                            tipe = c5.getString(c5.getColumnIndex(TabRegistry.TYPE)); 

                            status = c5.getString(c5.getColumnIndex(TabRegistry.STATUS)); 
                            number = c5.getString(c5.getColumnIndex(TabRegistry.NUMBER)); 
                        c5.moveToNext();
                        }
                       c5.close(); 

thanks in advance!

  • 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-02T17:13:50+00:00Added an answer on June 2, 2026 at 5:13 pm

    As I mentioned in my comment, if you are actually trying to find a particular item you need to actually look for it.

    Assuming you are looking to compare the status, you might do this:

    while(c5.isAfterLast() == false){   
        tipe = c5.getString(c5.getColumnIndex(TabRegistry.TYPE)); 
        status = c5.getString(c5.getColumnIndex(TabRegistry.STATUS)); 
        number = c5.getString(c5.getColumnIndex(TabRegistry.NUMBER)); 
        if (status.equals(comparisonString)){
            break;
        }
        c5.moveToNext();
    }
    

    This would break out of your loop, leaving your values set for the item you were looking for.

    Personally, that’s a lot of computing overhead and I’d just make the query to look for the comparison value directly and then check and see if the returned cursor was empty. Much simpler.

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

Sidebar

Related Questions

I am new in PL/SQL. I have a problem with loop in this language.
I have problem with fancybox. I want to write a function that will run
I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
i have problem with libhid . i found that there 2 way 4 accessing
so I have created this popup window with a custom move and sizing, pressing
I have created an application in Android that needs to send emails to all
I have some CSS code that hides the cursor on a web page (it
This is another stab into a problem I posted here . Please don't close
I have problem with using class instance in Python. Ive created a new class

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.