Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android applications what is the role of "R.java"? [closed]

Android applications have an automatically generated file called "R.java". Please explain its purpose.

E.g.

  • What is contained in it?
  • What generates it?

Duplicate: What is the concept behind R.java?

like image 347
pawarrohit14 Avatar asked Jul 28 '12 06:07

pawarrohit14


People also ask

What is the role of R Java file in an Android application?

Android R. java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory. If you create any component in the activity_main. xml file, id for the corresponding component is automatically created in this file.

What is r in Android app?

R class is generated by Android tools from your resources before compiling your code. It contains assigned numeric constant for each resource that you can refer in your project. For example, you have XML resource file that contains about_button .

What is the main function of class R in Android?

R is the class that contains all the resource ids for your application.

Where is the R Java file in Android Studio?

R. java is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r directory.


1 Answers

Every application uses resources such as strings, drawbles, layouts, and styles. Instead of hard coding such resources into an application, one externalizes them and refers to them by ID. The R.java file contains all those resource IDs, whether assigned by the programmer or generated by the sdk.

like image 141
jeet Avatar answered Sep 20 '22 05:09

jeet