0 votes
1 view
in Java by (3.9k points)

I am storing a SQL query in my strings.xml file and I want to use String. Format to build the final string in code. The SELECT statement uses alike, something like this:

SELECT Field1, Field2 FROM mytable WHERE Field1 LIKE '%something%'

In order to format that I replace 'something' with %1$s so it becomes:

SELECT Field1, Field2 FROM mytable WHERE Field1 LIKE \'%%1$s%\'

I escape the single quotes with the backslash. However, I am not able to escape the % sign.

How can I include a like statement in my strings.xml file?

1 Answer

0 votes
by (46.1k points)
To escape %, you will require to double it up: %%.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 30, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Jul 17, 2019 in Java by adam96 (800 points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...