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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:41:07+00:00 2026-05-25T14:41:07+00:00

I have a Sqlite DB that I’m accessing with a Cursor. I can scroll

  • 0

I have a Sqlite DB that I’m accessing with a Cursor. I can scroll through the cursor and run my “check();” method. the issue I’m having is when I scroll past the cursor.

ie: hitting my previous button when on the first entry or hitting my next button when on the last entry…

I tried to put in an if statement to automatically move to the proper location.

What I’m trying to do is if I’m on the first position and hit the previous button I want to move to the last position in the cursor and continue.

Also if the cursor is in the last position and tries to scroll past that I’d like it to go to the first position. Below is my attempt at trying to make this happen.

@Override
public void onClick(View v) {

    View src = v;
    switch (src.getId()) {
    case R.id.ButtonPrevious:       

        if  ((main.cursor.moveToPrevious()) ==  (main.cursor.moveToFirst()))
        {
            main.cursor.moveToLast();

        }else{
            main.cursor.moveToPrevious();   
        }                               
        check();



    case R.id.ButtonNext:


        if  ((main.cursor.moveToNext()) == (main.cursor.moveToLast()))
        {
            main.cursor.moveToFirst();

        }else{
        main.cursor.moveToNext();
        }
        check();
    }
}
  • 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-05-25T14:41:07+00:00Added an answer on May 25, 2026 at 2:41 pm

    You need to utilize the isAfterLast and isBeforeFirst methods of the Cursor class. Do something like this

    case R.id.ButtonPrevious:
        cursor.moveToPrevious();
        if (cursor.isBeforeFirst()){
            cursor.moveToLast();
        }
        check();
    case R.id.ButtonNext:
        cursor.moveToNext();
        if (cursor.isAfterLast()){
            cursor.moveToFirst();
        }
        check();
    

    Not all the code, but the critical part. Hope that helps.

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

Sidebar

Related Questions

I have a django project that uses a sqlite database that can be written
I have an SQLite table that contains a BLOB I need to do a
I have a SQLite database that contains a huge set of log messages. I
I have a SQLite DB that has people LastName, FirstName, Department and I need
I have what I would consider a small sized iPhone app that uses SQLite.
I have heard that prepared statements with SQLite should improve performance. I wrote some
I have noticed that Google Toolbox for Mac replaces several SQLite built-in functions (LOWER/UPPER,
I have a database file that is generated on a PC using Sqlite. This
I have created a Python module that creates and populates several SQLite tables. Now,
I have a small project that require a storage (I choose SQLite) and I

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.