I have experienced the same thing.

I'm guessing that item is a float or double, right?

The SQLiteDatabase class doesn't handle floating point properly in
this call. I've had to resort to version 2 in all my calls.

Although this doesn't work properly, I'm not sure it would be
considered a bug because of this:

selectionArgs   You may include ?s in selection, which will be replaced
by the values from selectionArgs, in order that they appear in the
selection. The values will be bound as *Strings*.

Bound as strings probably means that item=46.9876 reverts to
item='46.9876' down in the depths of SQLite. It has a different
meaning and item will be compared as a string, not numerically.

Unfortunately, I don't know an alternative to using option 2, unless a
new call were added that respected types, such as

public Cursor query (String table, String[] columns, String selection,
Object[] selectionArgs, String groupBy, String having, String orderBy,
String limit)

Nathan

On May 27, 11:04 am, JMichel <[email protected]> wrote:
> I was trying to figure out a problem with an SQLite query and I found
> that it was not working when I was using ? and a list of arguments.
> Could someone tell me why these two version of the code doesn't return
> the same thing:
>
> public Cursor getTagCursor(int item) {
>                 SQLiteDatabase db = getWritableDatabase();
>                 String [] col = {"_id", "type", "value", "item"};
>
>                 //VERSION 1 NOT WORKING
>                 String [] arg = {String.valueOf(item)};
>                 Cursor cursor = db.query ("tbl_tags", col, "item=?", arg, 
> null,
> null, "type ASC", null);
>
>                 //VERSION 2 SUCCESSFUL
>                 String test = "item="+String.valueOf(item);
>                 Cursor cursor = db.query ("tbl_tags", col, test, null, null, 
> null,
> "type ASC", null);
>
>                 return cursor;
>
> }
>
> Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to