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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:31:58+00:00 2026-05-25T17:31:58+00:00

I’m pritty new to Android and I’ve got a little question. I’ve got a

  • 0

I’m pritty new to Android and I’ve got a little question.
I’ve got a Problem with my ContextMenu. I have filled my ListView with my database entries, now i wand if i longclick it, that the ContextMenu pops up and there i want to delete or to edit my databaseentries:
But I don’t get how I can find out what entrie it is.

Here’s my Code..

    package de.retowaelchli.filterit.stats;




    import de.retowaelchli.filterit.R;
    import de.retowaelchli.filterit.database.ADFilterDBAdapter;
    import android.app.ListActivity;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.view.ContextMenu;
    import android.view.ContextMenu.ContextMenuInfo;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.SimpleCursorAdapter;

    public class CreatedADFilters extends ListActivity {

        //Variablen deklaration
        private ADFilterDBAdapter mDbHelper;

        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);

            //Kontext-Menu registrieren
            registerForContextMenu(findViewById(R.layout.list_layout));

            //Hier wir die Datenbank aufgerufen
            mDbHelper = new ADFilterDBAdapter(this);
            mDbHelper.open();
            fillData();

        }

       private void fillData() {

            // Get all of the notes from the database and create the item list
            Cursor c = mDbHelper.getAllADFilter();
            startManagingCursor(c);

            String[] from = new String[] { ADFilterDBAdapter.NAME, ADFilterDBAdapter.ROW_ID };
            int[] to = new int[] { R.id.label };

            // Now create an array adapter and set it to display using our row
           SimpleCursorAdapter adname =
              new SimpleCursorAdapter(this, R.layout.list_layout, c, from, to);
           setListAdapter(adname);

           mDbHelper.close();
       }


       //ContextMenu erstellen und definieren
      public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
           if (v.getId() == R.layout.list_layout) {
               getMenuInflater().inflate(R.menu.createdadmenu, menu);
           }
           super.onCreateContextMenu(menu, v, menuInfo);
       }

       public boolean onContextItemSelected(MenuItem item) {

           final AdapterView.AdapterContextMenuInfo info = 
                   (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

           switch (item.getItemId()) {
               case R.id.delete_adfilter: {
                   deleteAD();
                   return true;
               }
               case R.id.edit_adfilter:{
                   editAD();
                   return true;
           }
           return super.onContextItemSelected(item);
       }
      }

// THIS IS THE PART I DONT KNOW HOW TO REALIZE
       private void deleteAD(){
       }

       private void editAD(){
       }
    }

Thx for you Help in Advance!

best regards

safari

  • 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-25T17:31:58+00:00Added an answer on May 25, 2026 at 5:31 pm

    Your info local variable in onContextItemSelected() has an id data member which contains the _ID value from your Cursor. Here is a sample project demonstrating how to use that to delete an item based on a ListView context menu.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
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

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.