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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:34:56+00:00 2026-06-11T22:34:56+00:00

My ListView shows data from my SQLITE Database. By Longclick on a ListViewItem I

  • 0

My ListView shows data from my SQLITE Database.
By Longclick on a ListViewItem I delete this specific Item.
EveryThing works fine, but I don’t get my first item deleted. I don’t get any Errors in LogCat or something. Just nothing happens.

Here is my code from the Database class:

public void deleteEntry(String TABLE, int pos) {
    SQLiteDatabase database = this.getWritableDatabase();
    database.delete(TABLE, KEY_ROWID + "=?" , new String[] { String.valueOf(pos)});

    // also tryed this code
    database.delete(TABLE, KEY_ROWID + "= '" + pos +"'",null);
}

Here is the code of my ListView activity:

// Deletes the given row
            database.deleteEntry(MyDatabase.DATABASE_TABLE_ORDERS, position);
            updateList();

I’m quite shure that the committed int pos is representing the rowId of the respective Databse entry ( for the first entry pos is 0, for the second pos is 1 and so on )

updateList() creates a new listview and loads all the data from the DB again

Has anybody got an idea why i can delete all my Items in the ListView / rows in my DB besides my first entry? thx for your help!

  • 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-06-11T22:34:57+00:00Added an answer on June 11, 2026 at 10:34 pm

    After reading through your question a couple times I think what I initially posed in my comment is the issue…

    It appears to me that you are using the int pos parameter and thinking that it is the row id in the DB, that is not the case. The int pos parameter is the position in the list (which can be different from the row id depending on your sort, etc).

    The row id is contained in the long id parameter of the listener. The following changes should help you out (assuming my guess is correct).

    @Override
    public void onListItemClick(ListView l, View v, int pos, long id) {
           database.deleteEntry(MyDatabase.DATABASE_TABLE_ORDERS, id);  
           updateList();  
    }
    
    public void deleteEntry(String TABLE, long id) {   
        SQLiteDatabase database = this.getWritableDatabase();   
        database.delete(TABLE, KEY_ROWID + "=?" , new String[] { String.valueOf(id)});   
    
        // or this could be used
        database.delete(TABLE, KEY_ROWID + "= " + id ,null);   
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a listview that shows diferent data from my database. this works perfeclty.
I am displaying integer data from an SQLite database using a SimpleCursorAdaptor. Everything shows
I read data from an utf8 database then display it in a listview. but
I am getting the data from sqlite database and trying to display it in
I want to populate a listview from 2 tables in SQLite database. The listview
I have a listview connected to a custom array adapter. This list shows information
i am trying to fetch data from SQLite to list view but my list
In my application I have a sqlite database that looks like this: CREATE TABLE
I am new to android, using sqlite to insert data in database, and use
Hi I am developing an android in which I am loading data from database

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.