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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:23:14+00:00 2026-05-24T17:23:14+00:00

I would like to understand a line in a piece of code I saw:

  • 0

I would like to understand a line in a piece of code I saw:

public Cursor fetchMessageByMessageId(String msgId) {
    Cursor mCursor =

    mDb.query(true, DATABASE_MESSAGES_TABLE, new String[] { KEY_ROWID,
            KEY_CONVERSATION_ID, KEY_MSG_ID, KEY_TITLE, KEY_BODY,
            KEY_IS_REPLY, KEY_MEDIA_LOC, KEY_URL, KEY_TIMESTAMP },
            KEY_MSG_ID + "='" + msgId + "'", null, null, null, null, null);
    **if (mCursor != null) {
        mCursor.moveToFirst();
    }**
    return mCursor;
}

The following lines of code in between **

Is this line necessary? I spent 2 hours debugging today finding out why my data was missing when I called something like

while(mCursor.moveTonext())

use the cursor to grab some data and ended up missing the first data always. So I looked at my other parts of the code and realised that I dumped the whole cursor into the adapter so the bold line above had no effect whatsoever. After removing those lines of code everything was good!

So in short, if I just want a cursor with 1 result or many, is it necessary to call the bold statement above? Thanks!

  • 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-24T17:23:16+00:00Added an answer on May 24, 2026 at 5:23 pm

    Basically, you get a set of row when you call query(). Initially the cursor will be pointing to nothing. If you call mCursor.moveToNext() or mCursor.moveToFirst(), then you will want to point the the first row. Additional calls to mCursor.moveToNext() will move the cursor to next tuple.
    In short, only call mCursor.moveToNext() when you need to get information from next row (if it exists).

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

Sidebar

Related Questions

I would like to understand a bit better how to debug my iOS code
I would like to understand what Implement Interface Explicitly entails in C# based on
I would like to understand whats the best way to handle exceptions in Multicast
I would like to understand how Etherpad's timeline feature work. If you don't know
I would like to understand that what is Mesh Object and its conection with
I would like to understand what class << self stands for in the next
I would like to understand how object deletion works on python. Here is a
I am new to silver light and would like to understand a bit more
I am developing a Rails application and would like to understand when to use
I'm new to the subject of encoding and would like to understand it in

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.