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

  • Home
  • SEARCH
  • 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 6097779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:04:56+00:00 2026-05-23T13:04:56+00:00

I’m currently working through the notepad tutorial, and exercise 2 completes the code to

  • 0

I’m currently working through the notepad tutorial, and exercise 2 completes the code to delete notes. However, I’m slightly confused how this works. Here’s the relevant code:

public boolean onContextItemSelected(MenuItem item)
{
    switch (item.getItemId())
    {
        case DELETE_ID:
            AdapterContextMenuInfo info = 
                    (AdapterContextMenuInfo) item.getMenuInfo();
            mDbHelper.deleteNote(info.id);
            fillData();
            return true;
    }
    return super.onContextItemSelected(item);
}

The exercise states: “The id field of this [AdapterContextMenuInfo] object tells us the position of the item in the ListView. We then pass this to the deleteNote() method of our NotesDbAdapter and the note is deleted.”

Looking at the database definition, the id fields of newly added rows/notes to the database are auto-generated by an auto-incrementing number. Therefore, if we have 4 notes with id’s 1,2,3,4 (not sure if its zero indexed or not!) and delete the 2nd note, shouldn’t we be left with ids 1,3,4? Which means that trying to delete the last note (which is now 3rd in the list, but still with its original 4th index) should instead delete the row with the index=3? Or do the rows get auto-reindexed when a row gets deleted?

Finally, can you peek/browse the database on your phone for an app?

  • 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-23T13:04:57+00:00Added an answer on May 23, 2026 at 1:04 pm

    It seems to me that someone made a small mistake when writing the example’s text. If you see the documentation for the id field of AdapterContexteMenuInfo, it states that it returns the row id of the element. This is provided by your Adapter‘s getId() method.

    And, yes, you can read your phone’s database. You connect to the emulator shell (if you’re using the emulator) using this command from the command line:

       adb -e shell
    

    You then go into your application’s folder (in /data/data/com.yourpackage). There should be a databases folder. From the shell, type sqlite3 <databaseFileName>. You can then do any supported database operations (select, update, etc). Check this page out, it even has a section on sqlite3.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I have a JSP page retrieving data and when single or double quotes are

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.