On 12/17/2011 09:02 PM, Igor Tandetnik wrote: >>>> Using the Android API, I'd like to do something like SELECT * from >>>> my_table WHERE my_blob=? >>>> >>>> My problem is, all of the query methods only take strings as a parameter >>>> for the '?' placeholder. How am I supposed to pass in a byte array? >>> >>> http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#compileStatement(java.lang.String) >>> http://developer.android.com/reference/android/database/sqlite/SQLiteProgram.html#bindBlob(int, >>> byte[]) >> >> Thanks for your answer. However, AFAIK compiled statements cannot be >> used for queries (other than those returning only a single value). > > Yes you are right. There's another class, SQLiteQuery, that is used > internally by Cursor as a wrapper around a SQLite handle, and that has > bindBlob method. But there doesn't seem to be any convenient way to get to it. > > There may be one backdoor though. You should be able to write a class that > implements SQLiteDatabase.CursorFactory interface, and pass it to > SQLiteDatabase.queryWithFactory or rawQueryWithFactory. The method will turn > around and call newCursor on your factory, passing SQLiteQuery as a > parameter. You should be able to set the query's parameters, then just create > and return a new instance of SQLiteCursor (its constructor is public).
This works. Thanks for the hint! _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users