Use Placeholder with % sign in string.xml for String.format()

I am Using placeholder %1$d in string.xml for int value, and then I want to display % sign in same TextView so it's %. So I've use it like this.

<string name="uploadProgress">%1$d&#37;<string>

Now in Java Code I used it like this.

int progress = 10;
textView.setText(String.format(getString(R.string.uploadProgress), progress));

But it is showing:

java.util.UnknownFormatConversionException: Conversion:

I Tried with:

  1. % instead of &#37;
  2. Put a Space between %1$d and &#37;(But I don't want space actually.)

But no luck. How can I achieve this? I've looked another SO questions for solution but I'm not able to find particular one.


I've run into this as well. There are two ways to escape a literal percent symbol in XML string resources.

For your case (a string with parameters, e.g. %1$d) you should use %% to escape the percent symbol literal.

If your string does not have parameters, then you should use \u0025 to escape the literal percent symbol.

If you use %%in a string without parameters, then getString() will resolve it as a literal %% instead of escaping it. If you use \u0025 in a string with parameters, then getString() will crash trying to treat that % as a format parameter.


I have a SWT application which accepts the java type project and do some parsing mechanism on all the file, it was working fine but in large project which have a huge count of file it starts ...

I am running this code on EMR 4.6.0 + Spark 1.6.1 : val sqlContext = SQLContext.getOrCreate(sc) val inputRDD = try { inputRDD.filter("`first_field` is not null OR `...

With default methods now added to Java 8, is there any way to create a default constructor? I've tried: public interface KadContent<T> { public default KadContent() { } ... ...

Estoy usando elasticsearch 2.2.0 con la configuración predeterminada del clúster. Me encuentro con un problema con el escaneo y la consulta de desplazamiento usando spring data elasticsearch. Cuando ejecuto la consulta obtengo un error como este: [...