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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:19:29+00:00 2026-05-26T02:19:29+00:00

In Google’s Notepad tutorial for Android (http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html), they have the following for fetchNote /**

  • 0

In Google’s Notepad tutorial for Android (http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html), they have the following for “fetchNote”

/**
 * Return a Cursor positioned at the note that matches the given rowId
 * 
 * @param rowId id of note to retrieve
 * @return Cursor positioned to matching note, if found
 * @throws SQLException if note could not be found/retrieved
 */
public Cursor fetchNote(long rowId) throws SQLException {

    Cursor mCursor =

            mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
                    KEY_TITLE, KEY_BODY}, KEY_ROWID + "=" + rowId, null,
                    null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
    }
    return mCursor;

}

Why do we move the cursor to first if it’s not null? I know it works, but I don’t understand it. Why not just return the cursor? Why isn’t it pointing to the object we want?

  • 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-26T02:19:30+00:00Added an answer on May 26, 2026 at 2:19 am

    When you create the cursor object there is a slight chance that something could go wrong and the object wasn’t created and Null was returned by the mDb.query() method. If this is the case then trying to call mCursor.moveToFirst() will throw a NullPointerException. If the object isn’t null and has been initialized properly, then you call moveToFirst() presumably to put the cursor at the beginning of the list of items.

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

Sidebar

Related Questions

Google App Engine allows to administrate the Datastore http://code.google.com/appengine/docs/adminconsole/datastoreadmin.html but there is no mention
Google hosts popular ajax libraries for free at : http://code.google.com/apis/ajaxlibs/ You get to take
Google allows you to load jQuery asynchronously like so: <script src=http://www.google.com/jsapi?key=... type=text/javascript></script> <script> //<![CDATA[
Google have been suspended my android market account. I will get a new one
Google is failing me on this one. Let's say I have some ECMA script
Google just announced that they will add support for VoIP calls in its Gmail
GOOGLE MAPS API V3 is what i'm trying to use. I have all the
Google App Engine must have some sort of reverse caching proxy because when I
Google search + Google Chrome browser have this implemented, when you browse the google
Google hasn't helped me here nor has Microsoft online help yet. I have Inline

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.