You could also use query parameters to avoid any quoting issues,
including counting backslash-quotes (seems it's always a problem: did
you close the quotes around the literal? are there too many? too few?):
database.query(TABLE_NAME, projection, "COLUMN_NAME = ?", new String[] {
mySearchString }, null, null, sortOrder)
This also improves compiled query caching.
-- Kostya
13.01.2011 5:52, DanH пишет:
If you want the exact string you say , in effect:
COLUMN_NAME = 'my search string'
(single quotes)
On Jan 12, 7:07 pm, "Hendrik Greving"<[email protected]> wrote:
KEY_STRING is the text column name
When putting in KEY_STRING + " like " + mystring => I am getting a syntax
exception
KEY_STRING + " like \"" + mystring + "\"" => it seems to incorrectly always
find something
Actually, I want only exact matches, no substrings anyways
----- Original Message -----
From: Kostya Vasilyev
To: [email protected]
Sent: Wednesday, January 12, 2011 4:51 PM
Subject: Re: [android-developers] sqllite
Try using "like":
... where column like "%substring%"...
--
Kostya Vasilyev --http://kmansoft.wordpress.com
13.01.2011 3:42 пользователь "Hendrik Greving"<[email protected]>
написал:
> I have a database with a primary integer row key and several columns. One of the columns is "text".
Normally I am only fetching for the key, which is easy with SQLiteDataBase.query and KEY_ROWID =<mynumber> in
the selection field. How can I check whether a row (or more) exist that contain a certain string in the text column.
I've tried "MY_STRING_COLUMN = \"my_search_string\"" in the selection argument, but this doesn't
work.
> --
> 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
--
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
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
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