I have just found the same issue (issue #2 in the above post), but
maybe I can add some more insight.

If I include this code in my ContentProvideer query method:
<snip />
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
<snip />
        String _query = qb.buildQuery(projection, selection,
selectionArgs, groupBy, null, orderBy, null);
        Log.d(TAG,"Query="+_query);

        Cursor c = qb.query(mDb, projection, selection, selectionArgs,
groupBy, null, orderBy);

the string returned from qb.buildQuery is correct, but the actual SQL
generated internally by qb.query has an extraneous additional ")" at
the end of the where clause, and therefore throws an exception.

But, if I simply comment out the qb.buildQuery statement above (and
the Log.d call as well), the qb.query call works perfectly.  It seems
the qb.buildQuery call is leaving state in the SQLiteQueryBuilder
object that is not reset when the qb.query method is called.  I
spotted the same situation in the code originally posted at the start
of this email thread.

My first post here, so I hope it helps!

On May 6, 9:02 am, Jacky Boy <[email protected]> wrote:
> Thanks for your reply.
>
> What about the second question ?
>
> On May 4, 12:58 pm, Romain Guy <[email protected]> wrote:
>
> > > Q1: Method appendWhere can only append ONE query condition? why it
> > > named "append"?
>
> > Read the javadoc
> > (http://d.android.com/reference/android/database/sqlite/SQLiteQueryBui...)).
>
> > "Append a chunk to the WHERE clause of the query. All chunks appended
> > are surrounded by parenthesis and ANDed with the selection passed to
> > query(SQLiteDatabase, String[], String, String[], String, String,
> > String). The final WHERE clause looks like: WHERE (<append chunk
> > 1><append chunk2>) AND (<query() selection parameter>)"
>
> > So the behavior you are seeing is exactly what's described. If you
> > want to AND several conditions using appendWhere, you must put the AND
> > in each chunk.
>
> > --
> > Romain Guy
> > Android framework engineer
> > [email protected]
>
> > Note: please don't send private questions to me, as I don't have time
> > to provide private support.  All such questions should be posted on
> > public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
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