Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

int to String in Android

Tags:

string

android

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.

like image 568
beans Avatar asked Oct 20 '11 17:10

beans


People also ask

Can we convert int to string in java?

Method 1: Using toString Method of Integer Class The Integer class has a static method that returns a String object representing the specified int parameter. The argument is converted and returned as a string instance. If the number is negative, the sign will be preserved. Click here for the Complete Course!


2 Answers

String testString = Integer.toString(test); 
like image 65
SingleShot Avatar answered Sep 19 '22 04:09

SingleShot


Or you can use Use

String.valueOf()

eg.

int test=5; String testString = String.valueOf(test); 
like image 25
Francois Avatar answered Sep 19 '22 04:09

Francois