tags:

views:

1790

answers:

2

I've got an android app using a local sqlite database.

private SQLiteDatabase mDb;

when I run this query I get my Cursor over rows with pid equal to id, as desired:

mDb.query(true, PT_TABLE, new String[] {KEY_PID, KEY_TID}, 
    KEY_PID+" = "+id, null, null, null, null, null);

when I run the following query, aiming to get that same result set, ordered by pid I get "android.database.sqlite.SQLiteException: datatype mismatch"

mDb.query(true, PT_TABLE, new String[] {KEY_PID, KEY_TID}, 
    KEY_PID+" = "+id, null, null, null, null, KEY_PID+" DESC");

Any ideas?

+5  A: 

It looks like you got just a little mixed up. According to the SQLiteDatabase.query documentation, the last argument is the LIMIT clause. The second to last is the ORDER BY clause.

outis
A: 

KEY_PID+" = "+"'"+id+"'"

toto