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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:34:51+00:00 2026-05-28T23:34:51+00:00

Watch how i call the db.delete method; if I do the following a record

  • 0

Watch how i call the db.delete method; if I do the following a record is successfully deleted:

public void deteleProfile(Long id) throws SQLException {
        SQLiteDatabase db = helper.getWritableDatabase();
        Integer i = db.delete(ProlificDatabase.TABLE, "_id=?", new String[] {id.toString()});
        Log.d(TAG, i + " records deleted where id is " + id);

however if I do this:

public void deteleProfile(Long id) throws SQLException {
        SQLiteDatabase db = helper.getWritableDatabase();
        Integer i = db.delete(ProlificDatabase.TABLE, "?=?", new String[] {BaseColumns._ID,id.toString()});
        Log.d(TAG, i + " records deleted where id is " + id);

no records are deleted. also no exceptions or warnings are raised to say something has gone wrong.

in case you didn’t catch it, the difference between the two calls were:

..."_id=?", new String[] {id.toString()});

vs

..."?=?", new String[] {BaseColumns._ID,id.toString()});

documentation for BaseColumns._ID is:

public static final String _ID with a Constant Value: "_id"

The latter way seems to make for neater code, but why doesn’t it work?

EDIT:
I suspect the whereargs parameter only applies to the right side of an expression.

Can someone confirm this?

  • 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-28T23:34:52+00:00Added an answer on May 28, 2026 at 11:34 pm

    the Strings you provide in whereArgs are escaped and enclosed in ‘

    "?=?", new String[] {BaseColumns._ID,id.toString()});
    

    translates to

    '_id'='1234'
    

    which is valid SQLite syntax but does string comparison instead of a table lookup. Since “_id” is not the same String as “1234” (or any other number) the expression will always evaluate to false and nothing will get deleted.

    What you should use is the following syntax

    Integer i = db.delete(ProlificDatabase.TABLE, BaseColumns._ID + "=?", new String[] {id.toString()});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

1 - Method Chaining I really love the way you can call functions without
public Int64 ReturnDifferenceA() { User[] arrayList; Int64 firstTicks; IList<User> userList; Int64 secondTicks; System.Diagnostics.Stopwatch watch;
After calling MKMapView 's setCenterCoordinate:animated: method (without animation), I'd like to call selectAnnotation:animated: (with
http://www.youtube.com/watch?v=DyssOSmwuoo according to my video when call animation PageTransitionForward it will have a triangle
I am using the pattern from NerdDinner. I call Index() in my test Method
I watch a lot of tutorials on the web, expesially ASP.NET tutorials - And
I want to watch a folder tree on a network server for changes. The
I need to watch when certain processes are started or stopped on a Windows
I want to watch all the HTTP requests going out of a certain application
Anything one should watch out for when using CF8's CFFEED tag? Oh, here's a

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.