Int to String on Android

I get the resource identifier as follows:

int test = (context.getResourceId("raw.testc3")); 

I want to get the id and put it in a string. How can I do this? .ToString does not work.

+49
android string
Oct. 20 '11 at 17:16
source share
4 answers
 String testString = Integer.toString(test); 
+110
Oct 20 '11 at 17:19
source share

Or you can use Use

String.valueOf ()

eg.

 int test=5; String testString = String.valueOf(test); 
+18
Aug 05 '13 at 11:52
source share

Doing this very quickly if you don’t remember or don’t want to type long text:

 int a= 100; String s = ""+a; 
+3
Apr 27 '15 at 18:18
source share

What about:

 int a = 100; String s = String.format("%s", a); 
+2
Jan 03 '15 at 22:36
source share



All Articles