int to String in Android
AndroidStringAndroid Problem Overview
I get the id of resource like so:
int test = (context.getResourceId("raw.testc3"));
I want to get it's id and put it into a string. How can I do this? .toString does not work.
Android Solutions
Solution 1 - Android
String testString = Integer.toString(test);
Solution 2 - Android
Or you can use Use
> String.valueOf()
eg.
int test=5;
String testString = String.valueOf(test);
Solution 3 - Android
Very fast to do it if you dnt remember or dnt have time to type long text :
int a= 100;
String s = ""+a;
Solution 4 - Android
What about:
int a = 100;
String s = String.format("%d", a);