0

Possible Duplicate:
SQLite rawQuery selectionArgs and Integers Fields

Here is my table schema

create table Account (accountId) // accountId is long in practice

I am not able to use the parameter version of delete to delete a row given an long id. getPk() below returns a long id.

getDb().delete("Account", "accountId = ?", new String[]{ account.getPk().toString()});

However, I can workaround this by passing the parameter in the where clause.

getDb().delete("Account", "accountId = " + account.getPk().toString(), null);

My guess is that the parameter version of delete will work for string parameter but not integer/long parameter. Any insight?

EDIT: Another strange thing is, if I changed the table schema to below, both versions of delete work fine.

create table Account (accountId integer primary key autoincrement)
Community
  • 1
  • 1
PokerIncome.com
  • 1,708
  • 2
  • 19
  • 30
  • It's quite commonly confusing people... – Lukas Knuth Dec 26 '12 at 02:40
  • As i remember in android SQLite, it's internal implementation is a lil tricky i would say, even though they ask our preference as to what we want to define a column as, like int, text date boolean etc... but end of the day, it's jus a preference, it will not be used to when they store our data. So whatever type we choose our attributes to be, internally everything is basically a string representation. "The important idea here is that the type is recommended, not required." Check out the Type Affinity section in this link (http://www.sqlite.org/datatype3.html) – stack_ved Dec 26 '12 at 02:44
  • @PokerIncome.com i guess that's because you hinted the type and Android/SQLite is able to converted it internally. – Lukas Knuth Dec 26 '12 at 14:47

0 Answers0