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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:51:37+00:00 2026-06-03T20:51:37+00:00

I am using cursor to find out max id number then I need to

  • 0

I am using cursor to find out max id number then I need to go to 5 backwards of that record. For example, I am in id=9 and I want to go to id=5,How can I do it ?
I tried

int position=cursor.getPosition();  
cursor.moveToPosition(position-5);

But, It gives an error

 ID  TITLE     FOLDER   PARENT
    1   folder1      1        0
    2   item1        0        1
    3   item2        0        1
    4   folder2      1        1
    5   item1        0        4
    6   item2        0        4
    7   folder3      1        4
    8   item1        0        7
    9   item2        0        7

Cursor cursor = db.rawQuery(“SELECT id,title,folder,parent FROM mydata WHERE ” +
“id = (SELECT MAX(id) FROM mydata ); “,null);

  • 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-03T20:51:40+00:00Added an answer on June 3, 2026 at 8:51 pm

    You can try:

    cursor.moveToPosition(cursor.getCount() - 5);
    

    This assumes you have at least 5 items in the cursor.

    Update

    You are only requesting the details on the row with the highest id.

    To get your original request try this query:

    SELECT id,title,folder,parent FROM mydata
    

    With the code suggestion above.

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

Sidebar

Related Questions

I want to know how we can get record count using reference cursor in
I want to find out which facet is under the mouse cursor in an
How can I get a transparent cursor using Python GTK3 and pyGObject. I have
I've populated a ListActivity from a Cursor using SimpleCursorAdapter that starts another activity when
Using TDataSet.FindKey you can locate records. When it results in True the datasets cursor
Is is possible to find out the datatype of a column of a cursor
I'm using some of Firefox's specially-defined values for cursor, in particular -moz-zoom-in -moz-zoom-out -moz-grab
Using Mongokit with Python. Having some trouble working out get the last n number
I'm trying to figure out why occasionally I'm getting the IllegalStateException. I can't find
there! I want to find out how to change current line format in QTextEdit?

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.