int to String in Android

AndroidString

Android 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);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbeansView Question on Stackoverflow
Solution 1 - AndroidSingleShotView Answer on Stackoverflow
Solution 2 - AndroidFrancoisView Answer on Stackoverflow
Solution 3 - AndroidMaria GheorgheView Answer on Stackoverflow
Solution 4 - AndroidPerelanView Answer on Stackoverflow