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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:26:40+00:00 2026-05-20T05:26:40+00:00

I am trying to manage a simple list in an Android application. The contents

  • 0

I am trying to manage a simple list in an Android application. The contents of the list are maintained in a SQLite database. When the user selects and holds on a specific row, a context menu appears with a “Delete” option. When they select “Delete”, the row is deleted from the database, but the view does not refresh. When I back out of the application and get back in, the appropriate row has been removed. So, I know the row is deleted, it’s just the ListView that doesn’t refresh.

Here are the relevant bits of code…

In the onCreate method…

SQLiteDatabase db = tasks.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, 
    new String[] { _ID, TITLE, DETAILS, }, 
    null, null, null, null, TITLE + " DESC");
startManagingCursor(cursor);

ListView lv = (ListView) findViewById(R.id.list);
lv.setAdapter(new SimpleCursorAdapter(this, 
    android.R.layout.simple_list_item_1,
    cursor,
    new String[] {TITLE},
    new int[] { android.R.id.text1}
));

In the onContextItemSelected method…

switch(item.getItemId()) {
case 0:
    SQLiteDatabase db = tasks.getWritableDatabase();
    ListView lv = (ListView) findViewById(R.id.list);
    SimpleCursorAdapter adapter = (SimpleCursorAdapter) lv.getAdapter();
    db.delete(TABLE_NAME, "_ID=?", new String[] {adapter.getCursor().getString(0)});
    adapter.notifyDataSetChanged(); // Not working, clears screen and doesn't reload
    return true;
}
return super.onContextItemSelected(item);

What am I missing?

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-20T05:26:41+00:00Added an answer on May 20, 2026 at 5:26 am

    Get rid of the notifyDataSetChanged() and call requery() on your Cursor. Here is a sample project demonstrating this.

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

Sidebar

Related Questions

I'm trying to write a simple gui application to manage ruby version manager. I
I am trying to develop a simple application that polls events from a User's
I have a desktop application written in C#. It is trying to manage a
I am trying to write an application that displays the list of running applications.
Am trying to implement chrisbane's pull-to-refresh library for my ListView (https://github.com/chrisbanes/Android-PullToRefresh). It seems simple
I am trying to display all running apps on my android in a list
I am trying to create a simple program which displays a shopping cart list
im trying to write a simple gui form to display if any database connections
I'm trying to develop a simple WP7 database app which uses Linq2SQL to query
I am trying to use freetts for a simple java application but i am

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.