When using Android Studio, what is the purpose of the R.java file? Does the programmer insert Java code into it? Solution The programmer does not insert any code into the R.java file. Android R.java is an auto-generated file by Android SDK’s Android Asset Packaging Tool that contains resource IDs for all the resources of res/ directory. Every application uses resources such as strings, drawbles, layouts, and styles. Instead of hard coding such resources into an application, they are declared and defined externally and are referred by IDs. The R.java file contains all those resource IDs, whether assigned by the programmer or generated by the sdk. Generally, components are created in the activity_main.xml file. As soon as the component is created, the id for the corresponding component is automatically created in this R.java file. This id can be used in the activity source file to perform any action on the component. Example Create a file called \"/res/values/srings.xml\" <?xml version=\"1.0\" encoding=\"utf-8\"?> <resources> <string name=\"str1\">Hello</string> <string name=\"str2\">Hello World</string> </resources> Corresponding R.java file is public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int b1=0x7f050001; public static final int text1=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int str1=0x7f040000; public static final int str2=0x7f040001; } } .